Question Datagridview gotFocus on a particular cell

la_morte1977

New member
Joined
Apr 7, 2011
Messages
3
Programming Experience
Beginner
hello

I'm new here and I hope to be helped on this problem

I have a windows form with 8 textboxes, 3 datagridview (dgw1, dgw2, dgw3) and a picturebox


When entering the data, I have to click out of the current DataGridview3 (lose focus) to select a picturebox. After two clicks I need to go back into the cell where I was this datagridview.

I captured the coordinates of the cell and the datagrid like this:

VB.NET:
Private Sub DataGridView3_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellEnter
        datagridname = DataGridView3.Name
        col = e.ColumnIndex
        row = e.RowIndex
    End Sub

And on Doubleclick event I want to return on the cell where i was i this way
VB.NET:
DataGridView3.CurrentCell = DataGridView3(col, row)


I see that the function only highlights the cell. I can not move in the next cell if I press the Tab key


Use sendkeys to skip the Tabindex (
VB.NET:
SendKeys.Send("{TAB 3}")
), it seems too difficult, because the datagridview could contain variable rows. To go to the dgw3 must first pass through the dgw1 and dgw2.

Any idea how to solve this problem?
 
Select the DGV control again: DataGridView3.Select()
Since the grid selection has not changed you don't need to set CurrentCell first.
 
Thank you very much.

It work on a new project. I had to try it first in a new project and then on this project.

Some time ago I tried it and had not worked (in the actual project), because the fire goes in the textbox. Probably I have to check and find the error that I have in my code.
 
I found the error which he called the textbox1.focus() instead of the datagridview.select() into the jungle.

But now I have another problem.

If I am with Tab in a new row, if i lose the fire and after calling the DGW, the Tab jump on the last filled row and not on the new row.

Example: from cell (4, 2) must go to the cell (4, 3), where 1st value = row.index and 2nd value = column.index
when he loses focus and then returns, goes to the cell (3.3)

In cells that contain data already included, the problem does not exist.

Any idea how to solve this?
 
Example: from cell (4, 2) must go to the cell (4, 3), where 1st value = row.index and 2nd value = column.index
when he loses focus and then returns, goes to the cell (3.3)
I can't reproduce that. Current cell is not changed because of selecting different controls.
 
Back
Top