如何选中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; 新手求助 QQ如何实现的网页的一键登录 是什么原理呢? 添加一个打印按钮打印水晶报表中的报表,如何做。 这段JavaScript代码为什么无法执行 调整可以让它只显示地图 vb打开网页时有个pDisp的对象,请问C#对应的是什么?怎么才能知道frame是不是完全下载了? 如何让程序的窗口永远显示在最前面? 最牛的datagrid。功能超强,完全免费,源代码绝对开放。 在.NET2.0中打印控件怎么使用(C#)? 如何擴充PictureBox控件讓其支持AutoCad的*.dwg文件 如何实现将数据报表导出到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;