| | |
checkboxes in datagridview(windows application)
![]() |
•
•
Join Date: Jul 2007
Posts: 29
Reputation:
Solved Threads: 0
I am adding checkbox to datagridview.
how can I add a checkbox to the header so that when I click that all the checkboxes should be checked and corresponding rows should be deleted.. I am able to delete one row at a time. How to delete multiple rows..
Deleting one row...
Can anyone help me with the logic...
regards
venkat
how can I add a checkbox to the header so that when I click that all the checkboxes should be checked and corresponding rows should be deleted.. I am able to delete one row at a time. How to delete multiple rows..
C# Syntax (Toggle Plain Text)
DataGridViewCheckBoxColumn chkBoxColumn = new DataGridViewCheckBoxColumn(); chkBoxColumn.Name = "CheckBoxes"; dataGridView1.Columns.Add(chkBoxColumn);
Deleting one row...
C# Syntax (Toggle Plain Text)
private void btnDelete_Click(object sender, EventArgs e) { if (GlobalDataStore.GetInstance().CheckedStatus == true) { string fName = GlobalDataStore.GetInstance().FirstName; string relation = GlobalDataStore.GetInstance().Relation; string idcardno = GlobalDataStore.GetInstance().Idcardno; string query = "DELETE FROM DETAIL WHERE idcard_no = '" + idcardno.Trim() + "'" + " AND FM_NAME = '" + fName.Trim() + "'" + " AND rln_fm_nm = '" + relation.Trim() + "'"; DataSet ds = new DataSet(); OracleDataAdapter da = new OracleDataAdapter(query, this.connection); da.Fill(ds); DataTable dt = ds.Tables[0]; dt.Columns.Add("View"); DataRow dr = dt.NewRow(); dr["View"] = "View"; dt.Rows.Add(dr); dt.AcceptChanges(); DataView my_DataView = dt.DefaultView; dataGridView1.DataSource = my_DataView; connection.Close(); } }
Can anyone help me with the logic...
regards
venkat
Some hints perhaps on how I would start to handle this problem:
Use the properties SelectedCells, SelectedColumns, SelectedRows and SelectionMode.
Make also use of the event MultiSelectChanged.
Example : Select the checkbox column, change one checkbox in it and change all the others in your code accordingly.
I have not worked this out, but if I would have to do this, this is what I should try. Hope it helps.
Use the properties SelectedCells, SelectedColumns, SelectedRows and SelectionMode.
Make also use of the event MultiSelectChanged.
Example : Select the checkbox column, change one checkbox in it and change all the others in your code accordingly.
I have not worked this out, but if I would have to do this, this is what I should try. Hope it helps.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Other Threads in the C# Forum
- Previous Thread: Active X with C# error "ActiveX cannot create an object"
- Next Thread: Windows Event Logs
Views: 4345 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C#
.net 2d access algorithm application array asp.net assembly bitmap box button c# chat check checkbox class code color combobox control conversion csharp custom data database datagrid datagridview dataset datetime degrees directshow display dll drawing event excel exception file form format forms function gcd gdi+ graphics image index internet label list listbox login math multithreading mysql networking notepad office operator oracle outlook2007 picturebox pixel port print problem programming query radians remote remoting resource resourcefile saving search server sleep socket sql statistics string tcp text textbox threading timer treeview update url usb validation vc++ view visual webbrowser windows winforms wpf write xml







