I think the problem might be because I am using a Minding manager bound to a
comboBox and the datagrid. Maybe this is not the proper way of doing this.
It seems to work OK in every other aspect other than adding new records. I
tried your code and it worked better but only would select the current row.
I would like to go one step further and select the textbox in the first
column of the grid. The cboSearch Box will not clear even if I tell it that
its text = "" and/or its selectedIndex = -1. I think I am going to have to
loose that binding.
Here is my bind method:
Private Sub Bind()
Dim i As Integer
Dim lst As New DataTable
bmb = Me.BindingContext.Item(ds.Tables("ItemLocations"))
MyBase.DisplayPosition()
grdCatalog.ReadOnly = False
grdCatalog.TabStop = True
'Attach dataset's DefaultView to the datagrid control
'grdCatalog.DataSource = ds.Tables("ItemLocations").DefaultView
'no adding of new rows thru dataview...
lst = ds.Tables("ItemLocations")
grdCatalog.DataSource = ds.Tables("ItemLocations")
With cboSearch
..DataSource = ds.Tables("ItemLocations")
..DisplayMember = "LocationID"
..ValueMember = "LocationID"
..SelectedIndex = -1
..SelectedIndex = -1
End With
MyBase.bLoading = False
If ds.Tables(0).Rows.Count = 0 Then
MyBase.SetButtons(6) 'Empty dataset
Else
MyBase.SetButtons(0)
End If
bnewRow = False
End Sub
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
Hi Randy,
Normaly you have only to do this when that dataset is the datasource of
your datagrid and than it is the last row.
ds.Tables(0).rows.add(ds.tables(0).newrow)
DataGrid1.Select(ds.tables(0).Rows.Count - 1)
DataGrid1.CurrentRowIndex = ds.tables(0).Rows.Count - 1
However show us what is your datasource because when it is the dataview
with a sort in it, it is of course not this.
I hope this helps already a little bit.
Cor