how do i display data from checked box column row in the vb.net datagridview control

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi guys,
I am having trouble in allowing the user to select the row in the datagridview.
I managed to include the checkbox column in the datagridview but i do not know how to wrte the code such that when the user wants to update or edit the data in the checked row, he just have to check the affected rows checkbox, can be one or many, and
then click on ok button, which will then lead him to the data updater form, allowing him to update the data.
Currently i have the below code which can populate the checkboxclumn only.
Hope to hear from you guys!
<div style="color:Black;background-color:White; <pre>
dbProvider = <span style="color:#A31515; "PROVIDER=MICROSOFT.Jet.OLEDB.4.0;"

dbSource = <span style="color:#A31515; "Data Source = " & Form1.TextBox8.Text & <span style="color:#A31515; ""
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = <span style="color:#A31515; "SELECT * FROM CUSTOMERS_DETAILS"
da = <span style="color:Blue; New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, <span style="color:#A31515; "IAM_customer_database")

maxrows = ds.Tables(<span style="color:#A31515; "IAM_customer_database").Rows.<span style="color:Blue; Count
inc = -1


con.Close()

<span style="color:Blue; Dim MyTable <span style="color:Blue; As <span style="color:Blue; New DataTable

con.Open()

da.Fill(MyTable)

DataGridView1.DataSource = MyTable

<span style="color:Green; add new checkbpx column
<span style="color:Blue; Dim AddColumn <span style="color:Blue; As <span style="color:Blue; New DataGridViewCheckBoxColumn
<span style="color:Blue; With AddColumn

.HeaderText = <span style="color:#A31515; "Select"
.Name = <span style="color:#A31515; "Column Name that will be displayed"
.Width = 80


<span style="color:Blue; End <span style="color:Blue; With
DataGridView1.Columns.Insert(0, AddColumn)
MsgBox(DataGridView1.CurrentRow.Cells(1).Value.ToString())




con.Close()
[/code]





View the full article
 
Back
Top