Dany,
I did today another sample, so this one was easy to made from it.
\\\Needs only a datagrid on a form
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.DataSource = CreateTables()
DirectCast(DataGrid1.DataSource, _
DataTable).DefaultView.AllowNew = False
Dim dgts As New DataGridTableStyle
dgts.MappingName = "Persons"
Dim textCol As New DataGridTextBoxColumn
textCol.MappingName = "Name"
textCol.HeaderText = "Name"
textCol.Width = 200
textCol.ReadOnly = True
dgts.GridColumnStyles.Add(textCol)
Dim boolCol As New DataGridBoolColumn
boolCol.MappingName = "US"
boolCol.HeaderText = "US"
boolCol.Width = 20
boolCol.NullValue = False
dgts.GridColumnStyles.Add(boolCol)
DataGrid1.TableStyles.Add(dgts)
End Sub
'Sample datatable
Private Function CreateTables() As DataTable
Dim dtVBReg As New DataTable("Persons")
dtVBReg.Columns.Add("Name")
dtVBReg.Columns.Add("US", GetType(System.Boolean))
For i As Integer = 0 To 6
dtVBReg.Rows.Add(dtVBReg.NewRow)
Next
dtVBReg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", False}
dtVBReg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", True}
dtVBReg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", True}
dtVBReg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", True}
dtVBReg.Rows(4).ItemArray = New Object() _
{"Terry Burns", False}
dtVBReg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", True}
dtVBReg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", False}
Return dtVBReg
End Function
////
I hope this helps a little bit?
Cor
"Dany P. Wu" <da**@nospam.quicksilver.net.nz>
Hi everyone,
I'm not entirely sure if this is the best way of going about it, but
here's the scenario..........
I have two datagrid, each bound to a datatable which have checkbox
columns. There are two buttons between the datagrids, "Add" and "Remove".
They basically remove rows from one grid to the other, only those with the
checkbox ticked.
The problem is I don't want users to add new rows, or alter any of the
columns except for the checkbox column. Is this possible? Or perhaps is
there a better way of selecting multiple rows and working with them? I
realise I have to work with the underlying datasources, *not* the
datagrids themselves, but damn if I know how to go about it.
It's been bugging me all weekend. Any suggestions would be greatly
appreciated.
Cheers,
Dany.