1 / 6

軟體設計第二站 DataGridView 用法

軟體設計第二站 DataGridView 用法. Ren-Jie Wang, 王 仁 傑 , Ph.D. rjwanghtc@gmail.com 課程網頁 : http://rjwang.myweb.hinet.net. DataGridView 用在哪裏 ?. 軟體設計丙檢第二站作答時 , 在 VB2008 筆者建議使用 DataGridView 來顯示結果 940306 :身分證號碼檢查 940308 :分數加、減、乘、除運算. DataGridView 用法. DataGridView 最簡單 的操作順序如下:

nanji
Download Presentation

軟體設計第二站 DataGridView 用法

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. 軟體設計第二站 DataGridView用法 Ren-Jie Wang,王 仁 傑, Ph.D. rjwanghtc@gmail.com 課程網頁: http://rjwang.myweb.hinet.net

  2. DataGridView用在哪裏? • 軟體設計丙檢第二站作答時, 在VB2008筆者建議使用DataGridView 來顯示結果 • 940306:身分證號碼檢查 • 940308:分數加、減、乘、除運算

  3. DataGridView用法 • DataGridView最簡單的操作順序如下: • 1. 用.Columns.Add()方法定義欄位名稱及欄位標題 • 2. 用.Rows.Add() 方法加入資料列 • 3. 調整 DataGridView 顯示方式 • 用.Sort()方法指定某欄位排序方式 • 用.Columns().Width屬性調整欄位寬度

  4. DataGridView用法 • 假設DGV為DataGridView物件 • 1. 先定義欄位名稱 • DGV.Columns.Add(“ID NO”, “ID NO” ) • DGV.Columns.Add(“NAME”, “NAME”) • DGV.Columns.Add(“SEX”, “SEX”) • DGV.Columns.Add(“ERROR”, “ERROR”) • 2. 再加入資料列(必要時配合迴圈結構) • DGV.Rows.Add(d(i,1), d(i,2), d(i,3), d(i,4) )

  5. DataGridView用法 • 3. 調整 DataGridView 顯示方式 • 依某一欄位內容排序。例: 依據欄位1內容遞增排序 • Me.DGV.Sort(DGV.Columns(0), System.ComponentModel.ListSortDirection.Ascending) • 調整欄位寬度。例: 調整欄3寬度為50 • Me.DGV.Columns(2).Width = 50

  6. DataGridView用法 • 範例程式

More Related