The crystallographic, magnetic and electronic structures of the ferromagnetic shape memory alloys Ni2XGa (X=Mn, Fe, and Co), are systematically investigated by means of the first–principles calculations within the framework of density functional theory using the VIENNA AB INITIO SOFTWARE PACKAGE. The lattice parameters of both austenitic and martensitic phases in Ni2MnGa have been calculated. The formation energies of the cubic phase of Ni2XGa are estimated, and show a destabilization tendency if Mn atom is substituted by Fe or Co. From Ni2MnGa to Ni2CoGa, the down spin total density of states (DOS) at Fermi level is gradually increasing, whereas that of the up spin part remains almost unchanged. This is the main origin of the difference of the magnetic moment in these alloys. The partial DOS is dominated by the Ni and Mn 3d states in the bonding region below EF. There are two bond types existing in Ni2XGa: one is between neighboring Ni atoms in Ni2MnGa; the other is between Ni and X atoms in Ni2FeGa and Ni2CoGa alloys.