可以去查下MSDN,,但是03的好久以前用过。现在都是05了,LZ怎么还在用??
解决方案 »
- 如何用C# GUI 画动态的正弦线,就像示波器一样的
- timer中每天定时执行是怎么写的,求教
- 关于datalist和repeater的问题?在线等
- 创建excel.applacation异常
- winForm中,将记录插入到dbf(foxpro)文件时出错!
- 如何执行任务?
- listbox的滚动条是什么事件??如果没有,窗体过程怎么写????
- 请问怎么将字符数组置空?
- 组件类问题!建立了一个组件类,在其他地方怎么用组件类里面的元件?
- 正则表达式的匹配问题
- 关于DataSet中数据是不有变化,网上说用DataSet.GetChanges(),为什么我用的返回的不对呀....
- ScriptManager控件问题
添加一列可以用DataGridTextboxColumn类型,加上只读属性就是你要的label,它的MappingName属性对应到数据列上
要单元格的事件用currentcellchanged事件private void Form1_Load(object sender, System.EventArgs e)
{
RenderGrid();
this.dataGrid1.DataSource = GetData();
} private void RenderGrid()
{
DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridTextBoxColumn col = new DataGridTextBoxColumn();
col.HeaderText = "名称";
col.MappingName = "Name";
col.ReadOnly = true; tableStyle.GridColumnStyles.Add(col);
this.dataGrid1.TableStyles.Add(tableStyle);
} private object GetData()
{
DataTable table = new DataTable();
DataColumn col = new DataColumn("Name", typeof(string));
table.Columns.Add(col);
DataRow row = table.NewRow();
row[0] = "hello";
table.Rows.Add(row); row = table.NewRow();
row[0] = "world";
table.Rows.Add(row); return table; } private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
MessageBox.Show(this.dataGrid1[dataGrid1.CurrentCell].ToString());
}
去绑定
不要用DATAGRID