標籤:datagridview blog http 使用 io 資料 for ar
- 更加明了的顯示資料庫中的內容,更加方便的操作
- 使用DataGridView綁定資料集
| ColumnCount |
擷取或設定DataGridView中顯示的列數 |
| Coulumns |
擷取一個包含控制項中所有列的集合 |
| CurrentRow |
擷取包含當前單元格的行 |
| CurrentCell |
擷取或設定當前處於活動狀態的單元格 |
| DataMember |
擷取或設定資料來源中DataGridView顯示其資料的列表或表的名稱 |
| DataSource |
擷取或設定DataGridView所顯示資料的資料來源 |
| SelectedRows |
擷取使用者選定的行的集合 |
| |
|
DataGridView資料繫結
測試:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace DG{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { SqlDataAdapter sda = new SqlDataAdapter("select *from db_student","server=潘尚\\SQLEXPRESS;database=db_test;Trusted_Connection=true"); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; } }}
顯示結果: