qqqqqqqqqqqqqqqqqqqq 怎样将datagridview中得数据转换到ds中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 初期化的时候,把datagrid的datasource设置到对应的ds上,就不需要事后转换了。 如何将一张表绑定到datagridview控件上 如何将ds里面的数据绑定到dataGridView中,字段对应 http://wenku.baidu.com/view/0f8177eeaeaad1f346933f57.html http://topic.csdn.net/u/20091124/10/ada6f43c-15a4-4177-aeff-5209c3d0f149.html using System;using System.Windows.Forms;public enum Title{ King, Sir};public class EnumsAndComboBox : Form{ private DataGridView dataGridView1 = new DataGridView(); private BindingSource bindingSource1 = new BindingSource(); public EnumsAndComboBox() { this.Load += new System.EventHandler(EnumsAndComboBox_Load); } private void EnumsAndComboBox_Load(object sender, System.EventArgs e) { // Populate the data source. bindingSource1.Add(new Knight(Title.King, "Uther", true)); bindingSource1.Add(new Knight(Title.King, "Arthur", true)); bindingSource1.Add(new Knight(Title.Sir, "Mordred", false)); bindingSource1.Add(new Knight(Title.Sir, "Gawain", true)); bindingSource1.Add(new Knight(Title.Sir, "Galahad", true)); // Initialize the DataGridView. dataGridView1.AutoGenerateColumns = false; dataGridView1.AutoSize = true; dataGridView1.DataSource = bindingSource1; dataGridView1.Columns.Add(CreateComboBoxWithEnums()); // Initialize and add a text box column. DataGridViewColumn column = new DataGridViewTextBoxColumn(); column.DataPropertyName = "Name"; column.Name = "Knight"; dataGridView1.Columns.Add(column); // Initialize and add a check box column. column = new DataGridViewCheckBoxColumn(); column.DataPropertyName = "GoodGuy"; column.Name = "Good"; dataGridView1.Columns.Add(column); // Initialize the form. this.Controls.Add(dataGridView1); this.AutoSize = true; this.Text = "DataGridView object binding demo"; } DataGridViewComboBoxColumn CreateComboBoxWithEnums() { DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn(); combo.DataSource = Enum.GetValues(typeof(Title)); combo.DataPropertyName = "Title"; combo.Name = "Title"; return combo; } #region "business object" private class Knight { private string hisName; private bool good; private Title hisTitle; public Knight(Title title, string name, bool good) { hisTitle = title; hisName = name; this.good = good; } public Knight() { hisTitle = Title.Sir; hisName = "<enter name>"; good = true; } public string Name { get { return hisName; } set { hisName = value; } } public bool GoodGuy { get { return good; } set { good = value; } } public Title Title { get { return hisTitle; } set { hisTitle = value; } } } #endregion [STAThread] public static void Main() { Application.Run(new EnumsAndComboBox()); }} 控件随窗体缩放而缩放(调整布局) 仓库帐与财务帐怎么统一? C#.net中的sql语句 SQLite 插入多行记录问题,附代码求解 为什么VS2010每次新建项目的时候都会生成这个代码,然后调试都会出现这样的界面,怎么把它去掉 正则小问题 类型判断 问题!!!! 我导出excel文件用的是interop.excel 但是在office2003和officexp上可以 但是office2000不能导出成功 C# 写一个状态显示功能 c#调试成功后发布到 IIS 无法播放wav声音文件 求大师详细讲解 政治老师学编程2:接口是这样理解的吗?
using System.Windows.Forms;public enum Title
{
King,
Sir
};public class EnumsAndComboBox : Form
{
private DataGridView dataGridView1 = new DataGridView();
private BindingSource bindingSource1 = new BindingSource(); public EnumsAndComboBox()
{
this.Load += new System.EventHandler(EnumsAndComboBox_Load);
} private void EnumsAndComboBox_Load(object sender, System.EventArgs e)
{
// Populate the data source.
bindingSource1.Add(new Knight(Title.King, "Uther", true));
bindingSource1.Add(new Knight(Title.King, "Arthur", true));
bindingSource1.Add(new Knight(Title.Sir, "Mordred", false));
bindingSource1.Add(new Knight(Title.Sir, "Gawain", true));
bindingSource1.Add(new Knight(Title.Sir, "Galahad", true)); // Initialize the DataGridView.
dataGridView1.AutoGenerateColumns = false;
dataGridView1.AutoSize = true;
dataGridView1.DataSource = bindingSource1; dataGridView1.Columns.Add(CreateComboBoxWithEnums()); // Initialize and add a text box column.
DataGridViewColumn column = new DataGridViewTextBoxColumn();
column.DataPropertyName = "Name";
column.Name = "Knight";
dataGridView1.Columns.Add(column); // Initialize and add a check box column.
column = new DataGridViewCheckBoxColumn();
column.DataPropertyName = "GoodGuy";
column.Name = "Good";
dataGridView1.Columns.Add(column); // Initialize the form.
this.Controls.Add(dataGridView1);
this.AutoSize = true;
this.Text = "DataGridView object binding demo";
} DataGridViewComboBoxColumn CreateComboBoxWithEnums()
{
DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
combo.DataSource = Enum.GetValues(typeof(Title));
combo.DataPropertyName = "Title";
combo.Name = "Title";
return combo;
}
#region "business object"
private class Knight
{
private string hisName;
private bool good;
private Title hisTitle; public Knight(Title title, string name, bool good)
{
hisTitle = title;
hisName = name;
this.good = good;
} public Knight()
{
hisTitle = Title.Sir;
hisName = "<enter name>";
good = true;
} public string Name
{
get
{
return hisName;
} set
{
hisName = value;
}
} public bool GoodGuy
{
get
{
return good;
}
set
{
good = value;
}
} public Title Title
{
get
{
return hisTitle;
}
set
{
hisTitle = value;
}
}
}
#endregion [STAThread]
public static void Main()
{
Application.Run(new EnumsAndComboBox());
}}