79794896

Date: 2025-10-20 12:39:43
Score: 1.5
Natty:
Report link

I think that this problem is just about the focus. I have many winforms with a datagridview and I always use the same code to initialize a datagridview, which includes datagridview.ClearSelection(). And every time nothing is selected.

But I had this issue with one of my winforms where the first row of a datagridview was selected after startup. While debugging, I found out that this selection occured after finishing Form.Load(). Probably because this datagridview was the first control I put on this form.

To solve this problem I deleted the datagridview from my form and added a new one with the exact same name. The only thing that was different was the "TabIndex", which was 0 on the deleted datagridview and now it is 7. (But only changing this TabIndex doesn't work...) When I debugged again, the automatic selection didn't occured and now the focus was on the first button on the form...

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Wickedman1984