Click to See Complete Forum and Search --> : select rows from datagrid windows forms (vb.net)


renga2007
08-03-2004, 11:20 PM
Hi,

Having a datatable from dataset and assigned datasource for the
windows forms datagrid. created tablestyle with (checkbox) datagridboolcolumn. Below is the code works fine.

'vb.net formname=HdbExList
'datagridname = HdbExgrd
'table name = prop
'table stru : chk(bit [defa value 0]) this col used to select datagrid rows, street (varchar), unit(varchar),
'saledate (smalldatetime), remarks(varchar)

Private Sub HdbExList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim strQry as string = "select chk,street,unit,saleDate,remarks from Prop"
Dim SqlAda As New SqlDataAdapter(strQry, sConnection)
Dim H_DS As New DataSet

SqlAda.Fill(H_DS, "HDBEx")
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = H_DS.Tables("HDBEx").TableName
HdbExGrd.DataSource = H_DS
HdbExGrd.DataMember = H_DS.Tables("HdbEx").TableName

Dim chkCol As New DataGridBoolColumn
chkCol.MappingName = "Chk"
chkCol.HeaderText = " "
chkCol.Width = 15
chkCol.AllowNull = False
tableStyle.GridColumnStyles.Add(chkCol)

Dim column As New DataGridTextBoxColumn

column.MappingName = "Street"
column.HeaderText = "StreetName"
column.Width = 120
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Unit"
column.HeaderText = "Unit"
column.Width = 50
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "SaleDate"
column.HeaderText = "Date_Sold"
column.Width = 50
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Remarks"
column.HeaderText = "Remarks"
column.Width = 400
tableStyle.GridColumnStyles.Add(column)


HdbExGrd.TableStyles.Add(tableStyle)

End Sub

I need syntax for the below situation. plz anyone suggest me.

But i want to to user can select (check) few rows among the datagrid rows. and also a button click option for select all (check all) unselect all.(uncheck all) the whole. for this option i have included datagridboolcolumn.

selection is temporily coz the selected rows will be copied to another table for creating report.

the selection should not affect with original database. when the form load again the user has to reselect again.

if user move the arrow up & down (on datagrid) the concurrent remarks column has to be displayed on the form's textbox.

thanx for your time.

ppr