datagrid里怎么获取选中的当前行的序号?也就是第几行?怎么设置当前行的背景色???? 获取选中的当前行的序号:e.Item.ItemIndex 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 背景色private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ if(e.Item.ItemIndex!=-1){e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor);this.style.backgroundColor='#999999';this.style.cursor='hand';");e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');"); } 当前行的背景色:e.Item.BackColor=""; e后面怎么下拉不出item啊???????????? DataGrid1.Items[DataGrid1.SelectedIndex].BackColor=“”; 写在dataGrid的单击事件中,行吗? dataGrid的单击事件?单击事件好像是SelectedIndexChanged吧? dataGrid 有selectedindexchanged 吗??/怎么找不到???? selectedindexchanged事件你只要双击dataGrid 就能出来但我现在还不知道你要实现怎样的功能,能说详细点吗 第一个我想实现选定一行,该行的背景色变化.第二个,在dataGrid 中有一选择项内容,即,(checkBox类型),通过打勾选择,我要知道我选择了哪些行?? 双击出来的是这个事件啊!!private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne) { } 第一个问题你可以按照csl610(流浪者)的去做第二个问题:for(int i=0;i<this.DataGrid1.Items.Count;i++) { if(((CheckBox)this.DataGrid1.Items[i].FindControl("CheckBox1")).Checked = true) { return true; //表示这行已经选中 } } 晕 你是winform的啊 我还一直以为是WEB窗体呢 对,是winform,呵呵!谢谢!!!我试试看,好吗? 我的dataGrid1,就是下拉不出Items,怎么回事啊????????? http://dotnet.aspx.cc/ShowDetail.aspx?id=00C78024-5C08-4F3F-BCA8-AB3C0B330A12 dataGrid1.SelectionBackColor属性可以改变选定行的背景颜色。。 获取选中的当前行的序号int index=this.DataGrid1.SelectedIndex; http://blog.csdn.net/zhzuo/archive/2004/09/10/100882.aspx private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = this.DGwlInfo.HitTest(pt); WLkpRow=hti.Row; DataGrid1.Select(hti.Row);//置这一行为选定行 DGCModify(hti);}这样当前行就会被选定然后再用dataGrid1.SelectionBackColor设置选定行得背景色就可以了 WinForm下的DataGrid访问单元格的数据:DataGrid dataGrid = ......;// 比如要访问第1行第1列的数据:dataGrid[1,1].ToString();......你可以做个循环访问一整列。 获得当前行:dataGrid1.CurrentRowIndex C#更新access数据库时有参数为什么不正确 DataGridView多行循环添加问题,非连接数据库 C# 判断用户名并登陆 关于约束的问题 winform如何使TextBox的ScallBars的滑动条总处于最底下? webbrowser播放视频问题 static属性会被垃圾回收吗? 获取控件所有属性问题,请帮忙,急!!!!!!!! 请问如何在crystal report中打印dataview内容? 用c#的SmtpMail发mail我的smtp server需要身份验证怎么办? 如何设置DataGrid中某列的固定宽度 用程序写出ID的自增!
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex!=-1)
{
e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor);this.style.backgroundColor='#999999';this.style.cursor='hand';");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');");
}
但我现在还不知道你要实现怎样的功能,能说详细点吗
private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
第二个问题:for(int i=0;i<this.DataGrid1.Items.Count;i++)
{
if(((CheckBox)this.DataGrid1.Items[i].FindControl("CheckBox1")).Checked = true)
{
return true; //表示这行已经选中
}
}
int index=this.DataGrid1.SelectedIndex;
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.DGwlInfo.HitTest(pt);
WLkpRow=hti.Row;
DataGrid1.Select(hti.Row);//置这一行为选定行 DGCModify(hti);
}
这样当前行就会被选定
然后再用
dataGrid1.SelectionBackColor
设置选定行得背景色就可以了
DataGrid dataGrid = ......;
// 比如要访问第1行第1列的数据:
dataGrid[1,1].ToString();
......
你可以做个循环访问一整列。