I have a datagridview control on a form that I'm trying to select programmatically. My problem is, it's selecting the row in the grid when I use
Datagridview1.rows(Index).selected = True
However there is a margin on the left side of the datagrid that only get's the focus (or the little triangle identifier) when I click the row with my mouse.

Does anyone know how I can have this row fully selected using code. When I try to run another function of my form it's crashing because the datagridview is not fully selected.

I hope I am explaining this correctly, this seems like it should be simple but I am so new to datagridview programming that I am having many problems.

Any help from this forum would be greatly appreciated.

Thanks,

I put try...Catch logic in the function that were giving me the errors to display a message instructing the user to choose a record before continuing.

i don't know if this will help but try setting the row SelectionMode = fullrow
even temporallily.
then do
grid.row(index).selected = true

i don't know if this will help but try setting the row SelectionMode = fullrow
even temporallily.
then do
grid.row(index).selected = true

Thanks for replying to this post! I really appreciate your help, I've tried what you suggested and it didn't work. But I was able to get past the error message using the try...catch logic that I mentioned earlier. I guess for now I am simply going to requere the user to explicitly click a record in the datagrid before allowing them to delete, post, or approve an item in the grid. I think this should work fine for my users.

Thanks again for your help.

:cool:

In my programs i just use
grid.row(index).selected = true and it works like a charm. try playing around with your grids properties. also, try removing the rowheader(the column with star). i always remove it because it causes a lot of exceptions if you don't handle it correctly, and also i don't like the way it looks.
try posting some code so i can see it through this weekend

Edited 6 Years Ago by Mariandi: n/a

This question has already been answered. Start a new discussion instead.