i want to set first row as current row in datagrid view.
in vb we can it as
Thanks in advanceCode:grid.Row=1
Printable View
i want to set first row as current row in datagrid view.
in vb we can it as
Thanks in advanceCode:grid.Row=1
To set the CurrentRow you have to set the CurrentCell to a cell in the desired row. The first row has an index or 0, as with all .NET collections.
You want to select the first row in the datagrid view?
If it's that you just do this:
vb Code:
grid.Rows(0).Selected = True
mickey tats working
i want to display the records of first row to the corresponding textboxes , in which the data is selecting by the id (id is in 1st column) while loading the grid itself
You have a datagrid and textbox's and you want when the user select a row in the datagrid the values in the text box's reflect the values in the row?
I it's data you must set the text box's databindings...
NO mickey now its coming without seting databinding to the text boxes while clicking on the corresponding rows. what i want is display the the data of the first row while form loading
You can assign the values directly.... If you have all the values in the datagridview just do something like:
VB.NET Code:
TextBox1.Text = grid.Rows(0).Cells("ColName1").Value.ToString TextBox2.Text = grid.Rows(0).Cells("ColName2").Value.ToString ...
When the form loads? It takes so much time?
at the start of the program itself the form is loading. i have created function for loading the contents while clicking on the grid. the same function is loading while the form is loading. There is variable for loading the id while clicking the grid..Code:EditPatientId = CInt(grdPatients.Item(0, grdPatients.CurrentCell.RowIndex).Value.ToString())
the same variable suppose to load the first row's ID
it is solved by setting current cell in the form load and afte that i just call the function in which it is taking current cell's Vallue
Code:dataGrid.CurrentCell = dataGrid(0, 0)
Call funcGridOnClick()