SGUDAPAT
asked on
Help-Adding check boxes to data grid control and accessing them
Hi
I need to add to check box controls to the data grid view, when I am retreiving data from database, i.e I need to loop the check boxes such that how many ever rows I get from the database, these rows should have check boxes beside them.
I tried writing some code which is below, I was able to get check boxes, but I am not able to access them, i.e I am not able to check them, I also want something like SelectAll and UnSelectAll buttons, when I click on the SelectAll button, it should check all the check boxes and when I click UnselectAll button, it should be able to uncheck all check boxes.
And also one more thing, I don't why it is adding an extra empty row in the data gird view, how do I avoid that.
I need to add to check box controls to the data grid view, when I am retreiving data from database, i.e I need to loop the check boxes such that how many ever rows I get from the database, these rows should have check boxes beside them.
I tried writing some code which is below, I was able to get check boxes, but I am not able to access them, i.e I am not able to check them, I also want something like SelectAll and UnSelectAll buttons, when I click on the SelectAll button, it should check all the check boxes and when I click UnselectAll button, it should be able to uncheck all check boxes.
And also one more thing, I don't why it is adding an extra empty row in the data gird view, how do I avoid that.
If GetDataSet(DS, sSQL) Then
With DS.Tables("Table")
count = .Rows.Count
If .Rows.Count > 0 Then
'Populated the DataGridView with the data from the dataset
RDGVW.DataSource = DS.Tables("Table")
With Chkbx
.Name = "check"
.HeaderText = "Status"
End With
RDGVW.Columns.Add(Chkbx)
End If
End With
End If
code.doc
ASKER
Hi
Thank you for the response, how do I add the data table to data grid view?
I did something like
dt.Columns.Add("NO")
dt.Columns.Add("LINE")
and added the columns to data table, but how do I add the check boxes to the data table and and them to the data grid........ I am begginner in Vb.Net, please explain it to me.
Thank you for the response, how do I add the data table to data grid view?
I did something like
dt.Columns.Add("NO")
dt.Columns.Add("LINE")
and added the columns to data table, but how do I add the check boxes to the data table and and them to the data grid........ I am begginner in Vb.Net, please explain it to me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Solution has been posted. User can revisit to get answer at another time.
To check all/clear all, you simply would then loop through the grid and for each row set the value of that cell to 0.
Also, looking at your code, there is not enough there to determine why you get an extra row.