[英]Selecting whole row in dataGridView with my int indexCounter
在 Form1 上,我有 int indexCounter,它自動從文本框中獲取主鍵。
我怎么能說我的 Form2 上的 dataGridView1,它應該選擇我的 int indexCounter 所在的整行?
Form1 frm = new Form1();
dataGridView1.Rows[frm.indexCounter].Selected = true;
^ 這沒有用。 我正在使用綁定。
這很奇怪。 我創建了一個Form1
並設置了public int indexCounter = 3
,然后我使用你的 2 行codes
而不做任何修改來更新Form2
選定行並且它可以工作。
我認為您的indexConter
值以某種方式為 0,這將使所選 Row 為Rows[0]
。 您可能想要調試第二個代碼以在運行時查看indexCounter
的值
您沒有發布關於如何獲取indexCounter
值的indexCounter
,因此我無法進行更多測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.