ADO.NET之10-GridView---ShinePans

來源:互聯網
上載者:User

標籤:datagridview   blog   http   使用   io   資料   for   ar   

  1. 更加明了的顯示資料庫中的內容,更加方便的操作
  2. 使用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];        }    }}



顯示結果:





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.