国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#實(shí)現(xiàn)綁定DataGridView與TextBox之間關(guān)聯(lián)的方法

2020-01-24 01:31:22
字體:
供稿:網(wǎng)友

本文實(shí)例講述了C#實(shí)現(xiàn)綁定DataGridView與TextBox之間關(guān)聯(lián)的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace System.Windows.Forms.Samples{ public partial class Form1 : Form {  public Form1()  {   InitializeComponent();  }  private void Form1_Load(object sender, EventArgs e)  {   /* Create a DataSet with 1 DataTable */   DataSet  dataSet = new DataSet();   DataTable dataTable = dataSet.Tables.Add("Numbers");   dataTable.Columns.Add("ID", typeof(int));   dataTable.Columns.Add("Name", typeof(string));   dataTable.Rows.Add(0, "Zero");   dataTable.Rows.Add(1, "One");   CurrencyManager cm;   /* Get a CurrencyManager */   // cm = (this.BindingContext[dataSet, "Numbers"] as CurrencyManager);   /* This gets a different CurrencyManager */   cm = (this.BindingContext[dataTable] as CurrencyManager);   /* Bind left DataGridView and TextBox */   this.dataGridView1.DataSource = dataSet;   this.dataGridView1.DataMember = "Numbers";   this.textBox1.DataBindings.Add("Text", dataSet, "Numbers.Name", true);   /* Bind left DataGridView and TextBox */   this.dataGridView2.DataSource = dataTable;   this.textBox2.DataBindings.Add("Text", dataTable, "Name", true);  } }}

希望本文所述對大家的C#程序設(shè)計(jì)有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临沭县| 余干县| 福泉市| 香河县| 阿图什市| 博客| 澄城县| 祁阳县| 珠海市| 读书| 循化| 鄂托克前旗| 仲巴县| 麻阳| 应用必备| 五莲县| 义乌市| 伊金霍洛旗| 杨浦区| 英吉沙县| 大宁县| 宁阳县| 西平县| 花莲市| 临朐县| 梁山县| 会同县| 宿松县| 义乌市| 隆德县| 玛沁县| 乐业县| 沭阳县| 白沙| 淅川县| 阿坝| 互助| 古浪县| 甘泉县| 淅川县| 宝山区|