开发者

checkboxes with datagridview

I have a c# winform application (2008) with datagridview bound to data from sqlserver. I need to display checkboxes near each visible row of grid in order to select rows for further work, all the data in datagrid is readonly but is reload from time to time with different number of lines.

I need some advise and how to perform preferable idea:

-or to create programmatically checkboxes - then how should i know their locations (i want to place them once, of course :)), which data rows are d开发者_Go百科isplayed and how many?

-or to use checklistbox instead - then how should i create multiple columns bound to data and how to display columns titles?

-or maybe create additional checkbox column in datagrid - then how should i reload data to datagrid each time it's changed?

-or any other idea???

thanks!


You have to create addtional CheckBox column to perform operation .

For getting currently selected row value try

string value=DataGridView1.CurrentRow.Cells["cell1"].Value.ToString();

OR try

private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)

{
    chk = (CheckBox)e.Control;
    chk.CheckedChanged -=new EventHandler(chk_CheckedChanged);
    chk.CheckedChanged +=new EventHandler(chk_CheckedChanged);

}
 private void chk_CheckedChanged(object sender, EventArgs e)
      {  

      } 

And add this datagridviewCheckBoxColumn whenever you bind DataGridView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜