| 
                
                    |   | 為何遇到Number或int資料型態欄位,在User將資料清空後,卻發生無法移開該欄位? | 觀看回應 |  
                    |  | 這是 .net本身的機制,如果是數值內容,是不能清空的,如果真的也清空,.您可以用程式直接寫入到bindingSource裏,如下: (bindingSource.Current as DataRowView).Row["ColumnName"] = DBNull.Value;
 
 |  |  
 | 
		| 
                
                    |   | DataGridView中如何取出被選取資料內容值;如何撰寫全部選取? | 觀看回應 |  
                    |  | 1.infoDataGridView.SelectedRows就是當前選中的所有的Row。 用infoDataGridView. SelectedRows[index].Cells[index].Value來取目前資料的內容值。
 2. infoDataGridView.SelectAll();這個是全部選中。
 
 |  |  
 | 
		| 
                
                    |   | 如何設定DataGridView的header的text顏色? | 觀看回應 |  
                    |  | 如果DataGridView的ColumnType為InfoDataGridViewTextBox類型時,可以設定其HeadCellStyle屬性,但是,Header標題的顏色只有在windows經典風格下才會有效,如果不是經典的模式,建議改用粗體或者加*來提示。 |  |  
 | 
		| 
                
                    |   | Detail不是主鍵的欄位,如何做到可以新增卻不能更改? | 觀看回應 |  
                    |  | 可以在Detail的GridView設定CellBeginEdit事件,如下: private void infoDataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
 if  (e.RowIndex != infoDataGridView1.NewRowIndex) //更改而不是新增
 {
 if (e.ColumnIndex == 不希望修改的欄位在的列號)
 {
 e.Cancel = true;//拒絕修改
 }
 }
 }
 
 |  |  
 | 
		| 
                
                    |   | 為何在DataGridView中要刪除一筆資料,按 Delete鍵時,卻只是刪除第一個 Column的字元? | 觀看回應 |  
                    |  | 如果設定EditMode為EditOnEnter,那麼在選中的時候,常常會自動進入某個Cell的編輯狀態,這時候,鍵盤的操作對象是當前的Cell,而非GridView,所以這時候是無法刪除整筆記錄的。可以讓User點選到DataGridView的Header然後再按Delete鍵即可刪除。 |  |  
 |