C# 如何将焦点设置为DataGridView之外的对象
我有5个不同的表,它们绑定在Windows窗体上并使用C#。其中一个表是DataGridView。当我用下面的代码加载表单时,我想要聚焦的对象是自动的C# 如何将焦点设置为DataGridView之外的对象,c#,winforms,datagridview,C#,Winforms,Datagridview,我有5个不同的表,它们绑定在Windows窗体上并使用C#。其中一个表是DataGridView。当我用下面的代码加载表单时,我想要聚焦的对象是自动的 this.termsTableAdapter.Fill(this.terms_DataSet.Terms); this.customerTableAdapter.Fill(this.customer_Info_DataSet.Customer); this.customer_ShipTableAdapter.Fill(this.customer_
this.termsTableAdapter.Fill(this.terms_DataSet.Terms);
this.customerTableAdapter.Fill(this.customer_Info_DataSet.Customer);
this.customer_ShipTableAdapter.Fill(this.customer_Info_DataSet.Customer_Ship);
this.customer_MailTableAdapter.Fill(this.customer_Info_DataSet.Customer_Mail);
当我添加绑定DataGridView的行时,我无法将焦点设置为我希望使用.focus()设置为的控件,如下所示
this.customer_Ship_ContactsTableAdapter.Fill(this.customer_Info_DataSet.Customer_Ship_Contacts);
customerComboBox.Focus();
你知道为什么datagridview拥有焦点而不是我想要设置的控件吗
我可以在其他控件中单击以更改焦点,但我希望它设置为form_Load。焦点仅在窗体可见时有效,而在Load事件中,它还不可见 请尝试改用Select()方法:
customerComboBox.Select();
感谢LarsTech的快速响应。这是一个完美的答案。谢谢汉斯的迅速反应。这是一个完美的答案