1 / 22

GridView 操作 (II)

GridView 操作 (II). 資料錄移動. 使用 BindingSource 元件. 修改 LOAD SQL DATA. 修改 UPDATE DATA. 移動到下一筆. 資料錄移動. 使用 BindingNavigator 元件. 設定 BindingSource 屬性 =BindingSource1. 新增按鈕. 呼叫存檔按鈕程式. ‘ 全部欄位數 MessageBox.Show(DataGridView1.Columns.Count.ToString()) ‘ 控制欄位標題文字 ( 例如第一個欄位的名稱 )

sana
Download Presentation

GridView 操作 (II)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GridView操作 (II)

  2. 資料錄移動 使用BindingSource元件

  3. 修改LOAD SQL DATA

  4. 修改UPDATE DATA

  5. 移動到下一筆

  6. 資料錄移動 使用BindingNavigator元件

  7. 設定BindingSource屬性=BindingSource1

  8. 新增按鈕

  9. 呼叫存檔按鈕程式

  10. ‘全部欄位數 MessageBox.Show(DataGridView1.Columns.Count.ToString()) ‘控制欄位標題文字(例如第一個欄位的名稱) DataGridView1.Columns(0).HeaderText = “欄位名稱“ ‘取出選取列的內容(例如第一個欄位的內容) DataGridView1.CurrentRow.Cells(0).Value.ToString() ‘設定某個欄位是唯讀 (例如設定第二個欄位是唯讀) DataGridView1.Columns(1).ReadOnly = True GridView其他設定

  11. ‘選取列的前景與背景色 DataGridView1.DefaultCellStyle.SelectionForeColor = Color.Aqua DataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkGreen ‘凍結欄位 (例如凍結前兩個欄位) DataGridView1.Columns(0).Frozen = True DataGridView1.Columns(1).Frozen = True GridView其他設定

  12. GridView • F2可以進入編輯模式 • 自動排序 (點選標題名稱) • 自動內容大小功能 (雙擊標題的分隔線) • 凍結欄位 • 使用者拖拉欄位顯示順序AllowUserToOrderColumns屬性 • 設定隔列顯示不同顏色AlternatingRowsDefaultCellStyle屬性裡面的forecolor

  13. 加入自訂欄位

  14. 使用自訂欄位

More Related