如何选中DataGrid控件中一个单元格的内容 在线等待 foreach(DataGridItem dg in DataGrid.Items){ dg.Cells[index(列数)] //如此可以访问所有的单元格} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 this.dataGrid.CurrentCell就是你想要的 add a MouseUp event handler for the DataGrid:void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt); if(hti.Type == DataGrid.HitTestType.Cell) { TextBox1.Text = DataGrid1[hti.Row, hti.Column].ToString(); } } 我是这样使用的,你可参考一下:string sYear,sMonth;int pos=this.BindingContext[dsBb1,"cktsjhhzb"].Position;DataTable dt=dsBb1.Tables[0];sYear=dt.Rows[pos]["nian"].ToString().Trim();sMonth=dt.Rows[pos]["yue"].ToString().Trim();txtBbYear.Text=sYear;txtBbMonth.Text=sMonth; 谁能给个sql数据库保存图片的例子 Devpress.XtraGrid.GridControl.GridView 管理软件的窗体问题! 如何写文件。在线等。 小弟初学C#写程序,有两个小问题! 各种模式的比较???????????? 在C#中如何改变文件的扩展名(后缀)? OpenXml 获取word文档的页数 C#下用rs232串口通讯问题 安装了框架是否就可以调试C#了,我怎么看不到呢 如何实现将数据报表导出到Excel? 求教SQL Server 连接问题!
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
TextBox1.Text = DataGrid1[hti.Row, hti.Column].ToString();
}
}
int pos=this.BindingContext[dsBb1,"cktsjhhzb"].Position;
DataTable dt=dsBb1.Tables[0];
sYear=dt.Rows[pos]["nian"].ToString().Trim();
sMonth=dt.Rows[pos]["yue"].ToString().Trim();
txtBbYear.Text=sYear;
txtBbMonth.Text=sMonth;