April 11, 2010

How to add CheckBox in DataGrid in Win Application

Create the Data Grid at runtime


it will ease ur problems

First add a datagridview control 2 ur form

than


Code 4 implement columns

public void creategrid() //call it on on load even of form or button click(or any event)

{

DataGridViewTextBoxColumn tbc0=new DataGridViewTextBoxColumn ;

tbc0.name="EmpName" ;


tbc0.HeaderText="Emp Name" ;


tbc0.width=150 ;


this.datagridview1.Columns.Insert(0,tbc0);


DataGridViewCheckBoxColumn tbc1=new DataGridViewCheckBoxColumn ;


tbc1.name="EmpStatus" ;

tbc1.HeaderText="Emp Status" ;


tbc1.width=50 ;


this.datagridview1.Columns.Insert(1,tbc1);

DataGridViewComboBoxColumn tbc2=new DataGridViewComboBoxColumn ;


tbc2.name="EmpDesignat" ;


tbc2.HeaderText="Emp Designation ;


tbc2.width=50 ;

this.datagridview1.Columns.Insert(2,tbc2);


}
 
This is just one way of doing it at runtime.
 
Happy coding....
 
SanketKingkong

No comments: