0
我有一個允許多選的c#數據網格對象。在Windows XP中,它工作正常,但在Windows 7中,光標從網格中移出後,以前選定的行(使用Ctrl或Shift鍵)在一段時間後重設(未選中)。在Windows XP中,這樣的事情不會發生,選定的行總是被選中,除非用戶取消選擇。如何防止已選定的行自動在c#datagrid中被取消選中
這裏是我的網格:
this.dgAlindiListesi.AllowUserToAddRows = false;
this.dgAlindiListesi.AllowUserToDeleteRows = false;
this.dgAlindiListesi.AllowUserToResizeRows = false;
this.dgAlindiListesi.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgAlindiListesi.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgAlindiListesi.BackgroundColor = System.Drawing.Color.White;
this.dgAlindiListesi.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
this.dgAlindiListesi.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgAlindiListesi.Location = new System.Drawing.Point(23, 269);
this.dgAlindiListesi.Name = "dgAlindiListesi";
this.dgAlindiListesi.ReadOnly = true;
this.dgAlindiListesi.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgAlindiListesi.Size = new System.Drawing.Size(830, 359);
this.dgAlindiListesi.TabIndex = 1;
我將不勝感激任何建議。
預先感謝您
我在windows7中運行了你的datagrid設置。光標從網格中移出時不會取消選擇。我認爲你的上面的代碼很好,但其他代碼有問題,如管理鼠標或焦點。 – hyun