|
-
Aug 18th, 2009, 06:06 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Datagrid View Current Row
i want to set first row as current row in datagrid view.
in vb we can it as
Thanks in advance
-
Aug 18th, 2009, 06:16 AM
#2
Re: Datagrid View Current Row
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.
-
Aug 18th, 2009, 06:18 AM
#3
Re: Datagrid View Current Row
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
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Aug 18th, 2009, 06:23 AM
#4
Thread Starter
Addicted Member
Re: Datagrid View Current Row
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
-
Aug 18th, 2009, 06:34 AM
#5
Re: Datagrid View Current Row
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...
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Aug 18th, 2009, 06:57 AM
#6
Thread Starter
Addicted Member
Re: Datagrid View Current Row
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
-
Aug 18th, 2009, 07:00 AM
#7
Re: Datagrid View Current Row
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?
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Aug 18th, 2009, 07:10 AM
#8
Thread Starter
Addicted Member
Re: Datagrid View Current Row
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
-
Aug 19th, 2009, 01:17 AM
#9
Thread Starter
Addicted Member
Re: Datagrid View Current Row
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()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|