Place flashing cursor inside datagrid cell

chatelain

New member
Joined
Sep 8, 2006
Messages
2
Programming Experience
Beginner
So far I have not found any successful code to select a specific cell, select the text inside a specific cell or simply place the flashing cursor inside a specific cell. It starting to appear as impossible but I'm not convinced yet.
The end goal is when a new row is added, the cursor is placed inside cell 0,0.
Please help! Thanks in advance.
 
Here is the solution to the problem:
VB.NET:
        Dv.AllowNew = True 'This makes it so new rows can be added
        Table.Clear() 
        DataGrid1.TableStyles(0).GridColumnStyles(0).ReadOnly = False
        Dim NewRow As DataRow
        NewRow = Table.NewRow
        Table.Rows.Add(NewRow)
        Dv.AllowNew = False 'This makes it so there is not an extra empty line at the bottom
        'The following 7 lines make it possible to select the text in the specified cell
        DataGrid1.Focus()
        Dim Dgc As DataGridCell = New DataGridCell(0, 0) 'Specify cell address
        DataGrid1.CurrentCell = Dgc
        Dim Ts As DataGridTableStyle
        Ts = DataGrid1.TableStyles(0)
        Dim DgTb As DataGridTextBoxColumn = CType(DataGrid1.TableStyles(0).GridColumnStyles(0), DataGridTextBoxColumn)
        DgTb.TextBox.Focus()
I had this code the whole time but had the Dv.AllowNew = False at the end which made the selection lose focus.
 
Back
Top