winform 中 datagrid 单击选中整行 而不是单元格 winform 中 datagrid 单击选中整行 而不是单元格怎么做啊现在 一点就是选中单元格 我要选中整行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { if (this.tempTable.Rows.Count > 0) { int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber; if (currentRowNumber >= 0 && currentRowNumber < fbackAMend.Count) fbackAMend.Position = currentRowNumber; } } private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { if (this.tempTable.Rows.Count > 0) { int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber; if (currentRowNumber >= 0 && currentRowNumber < fbackAMend.Count) fbackAMend.Position = currentRowNumber; } }可不可以解释下 fbackAMend 是什么。。 修改datagrid的SelectionMode属性为FullRowSelect 修改datagrid的SelectionMode属性为FullRowSelect private void dgDb_ItemCreated(object sender, DataGridItemEventArgs e){ e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'"); e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");}改成 onclick 就可以了 SelectionMode是VS2005中DataGridView的属性 tcx1986() 你这个是WebForm的winform2003中,要改DataGrid的行选种模式,只能重绘了 private void dgGrid_CurrentCellChanged(object sender, System.EventArgs e) { this.dg_dgGrid.Select(this.dg_dgGrid.CurrentRowIndex); } private void dgGrid_CurrentCellChanged(object sender, System.EventArgs e) { this.dgGrid.Select(this.dgGrid.CurrentRowIndex); } 还没结贴我来说吧,但要给分呀!楼上几位说的不如我这个简单——哈哈!pivate void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { Point pt = new Point(e.X,e.Y); DataGrid.HitTestInfo hit = dataGrid1.HitTest(pt); if(hit.Type == DataGrid.HitTestType.Cell) { dataGrid1.Select(hit.Row); } } 回答楼主private CurrencyManager fbackAMend; //--------------------初始化窗体,读入数据------------------ private void cFbackEditA_Load(object sender, System.EventArgs e) { this.sqlDataAdapter1.Fill(tempTable); this.dataGrid1.DataSource = tempTable.DefaultView; DataGridStateControl(); DataBindingsFunction(); fbackAMend = (CurrencyManager) BindingContext[tempTable]; } 重写的确可以 但是程序都做好了 好麻烦啊。 TO:天天在线 不行啊 N 早就用过 TO:一路狂奔 不行啊 也用过 TO:可乐 明天去试试 明天结贴 现在在家 不好意思。 还没结贴我来说吧,但要给分呀!楼上几位说的不如我这个简单——哈哈!pivate void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){Point pt = new Point(e.X,e.Y);DataGrid.HitTestInfo hit = dataGrid1.HitTest(pt);if(hit.Type == DataGrid.HitTestType.Cell) {dataGrid1.Select(hit.Row); }}编译能过吗我要的是 选中它 且单元格不接受焦点。 呵呵,看来此分非我莫属啦。我用的是vs2005//选择某行 datagridview1.Rows[3].Selected = true; private 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) { dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column); dataGrid1.Select(hti.Row); } } http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q689q this.dataGrid1.CurrentRowIndex=this.dataGrid1.CurrentCell.RowNumber; this.dataGrid1.CurrentRowIndex=this.dataGrid1.CurrentCell.RowNumber;这样 还是触发不了 datagrid 的双击事件 事件被 cell接收了。 this.dg_dgGrid.Select(this.dg_dgGrid.CurrentRowIndex); this.dg_dgGrid.Select(this.dg_dgGrid.CurrentRowIndex);没用 是点击进单元格了 private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e){ dataGrid1.Select(dataGrid1.CurrentRowIndex) ;} MdiParent 窗体禁止最大化问题 这个怎么做 检测出停机,空号,关机的手机号码, 求解 今天文思的笔试算法题 关于对象概念的一个问题 求教---《BEGINNING C# 入门经典》为什么我的MenuItemFiles 中没有Top level属性 存储过程与断开式连接能否共存? 怎样在我最大化窗口时全屏显示(就是将“开始”任务兰一起填充)(就象进入游戏时的全屏效果一样,进入屏保时也是) 怎样防止文本框输入非法字符 急啊``像这样的函数aa(int** b),在C#里怎样调用啊? How to bind muti-DataTable to one DataGrid(GridView)?
{
if (this.tempTable.Rows.Count > 0)
{
int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber;
if (currentRowNumber >= 0 && currentRowNumber < fbackAMend.Count)
fbackAMend.Position = currentRowNumber;
}
}
{
if (this.tempTable.Rows.Count > 0)
{
int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber;
if (currentRowNumber >= 0 && currentRowNumber < fbackAMend.Count)
fbackAMend.Position = currentRowNumber;
}
}
可不可以解释下
fbackAMend 是什么。。
{
e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
改成 onclick 就可以了
winform2003中,要改DataGrid的行选种模式,只能重绘了
{
this.dg_dgGrid.Select(this.dg_dgGrid.CurrentRowIndex);
}
{
this.dgGrid.Select(this.dgGrid.CurrentRowIndex);
}
我来说吧,但要给分呀!
楼上几位说的不如我这个简单——哈哈!
pivate void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point(e.X,e.Y);
DataGrid.HitTestInfo hit = dataGrid1.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dataGrid1.Select(hit.Row);
}
}
private CurrencyManager fbackAMend;
private void cFbackEditA_Load(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.Fill(tempTable);
this.dataGrid1.DataSource = tempTable.DefaultView;
DataGridStateControl();
DataBindingsFunction();
fbackAMend = (CurrencyManager) BindingContext[tempTable];
}
我来说吧,但要给分呀!
楼上几位说的不如我这个简单——哈哈!
pivate void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point(e.X,e.Y);
DataGrid.HitTestInfo hit = dataGrid1.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dataGrid1.Select(hit.Row);
}
}编译能过吗我要的是 选中它 且单元格不接受焦点。
我用的是vs2005
//选择某行
datagridview1.Rows[3].Selected = true;
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
dataGrid1.Select(hti.Row);
}
}
this.dg_dgGrid.Select(this.dg_dgGrid.CurrentRowIndex);
没用 是点击进单元格了
{
dataGrid1.Select(dataGrid1.CurrentRowIndex) ;
}