Programatically adding checkboxes to datagridview
-
Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.
-
Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.
-
The same question was asked few threads earlier: http://www.codeproject.com/Messages/3071608/Dynamically-adding-checkboxes-in-datagridview.aspx[^] Regards Saanj
Either you love IT or leave IT...
Hi, That question was raised by me itself but, I couldn't find right answer. One who suggested me at design time instead of runtime. Please help. :)
-
Hi, That question was raised by me itself but, I couldn't find right answer. One who suggested me at design time instead of runtime. Please help. :)
Does the textbox reside inside the grid view or some where else? Are you trying to say that on the textchanged event of the textbox, checkbox lists should be created with the data that depends upon the textbox's text right. You can add a Template Column in the gridview. Drag a checkbox list in the ItemTemplate. Set the autpostback to true ande define an event. This event will be common for all checkboxes in your gridview. Now in the RowDataBound event of your gridview, just set the items of the checkbox list depending upon the data that you want to bind. As you have already set the event with the checkbox list, you can do what ever you want in the checkboxlist selected index changed event. It's a bit long discussion but I hope something is clear now If I took your words right. :) Regards Saanj
Either you love IT or leave IT...
-
Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.
You can add a COLUMN of checkboxes, you cannot add a chackbox to a single row. I use the following:
DataGridViewCheckBoxColumn oDGC = new DataGridViewCheckBoxColumn();
oDGC.HeaderText = "Sel";
oDGC.Name = "Sel";
oDGC.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
oDGC.FlatStyle = FlatStyle.Standard;
oDGC.CellTemplate = new DataGridViewCheckBoxCell();
oDGC.CellTemplate.Style.BackColor = System.Drawing.Color.Beige;
oDGC.ThreeState = false;
oDG.Columns.Insert(iCol, oDGC);Never underestimate the power of human stupidity RAH
-
Does the textbox reside inside the grid view or some where else? Are you trying to say that on the textchanged event of the textbox, checkbox lists should be created with the data that depends upon the textbox's text right. You can add a Template Column in the gridview. Drag a checkbox list in the ItemTemplate. Set the autpostback to true ande define an event. This event will be common for all checkboxes in your gridview. Now in the RowDataBound event of your gridview, just set the items of the checkbox list depending upon the data that you want to bind. As you have already set the event with the checkbox list, you can do what ever you want in the checkboxlist selected index changed event. It's a bit long discussion but I hope something is clear now If I took your words right. :) Regards Saanj
Either you love IT or leave IT...
Sir, Your first statement was right that I m having textbox outside to that of datagridview. You gave the code which was in ASP.NET but,I m working on C# Windows. Even I succeeded in adding checkboxes at runtime on textchange event of external checkbox on your behalf....Thanks. But, now I m quering about how will I get the appropriated row record on clicking respective checkbox on the row ? Is there any event about databinding events to succeed further? I want to check it for furher process. Please help. awaiting................. :-O
-
Sir, Your first statement was right that I m having textbox outside to that of datagridview. You gave the code which was in ASP.NET but,I m working on C# Windows. Even I succeeded in adding checkboxes at runtime on textchange event of external checkbox on your behalf....Thanks. But, now I m quering about how will I get the appropriated row record on clicking respective checkbox on the row ? Is there any event about databinding events to succeed further? I want to check it for furher process. Please help. awaiting................. :-O