一个关于DataGridView的简单问题!(在线等!) 小弟用DataGridView绑定数据,运行显示出来,但是不符合我的要求;我想点击一行中的某个字段就会全部选择这一行,而不是选择这个字段(就是把一行都变蓝色,而不是这个字段显示蓝色),不知道我该怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 添加上事件private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemIndex==-1) return; e.Item.Attributes.Add("style","cursor:hand"); e.Item.Attributes.Add("onMouseOver=this.style.backgroundColor","#add8ef"); e.Item.Attributes.Add("onMouseOut=this.style.backgroundColor","");}你试一下,我做的比较简单! 不好意思 没发完int itemIndex=e.Item.ItemIndex; itemIndex=Convert.ToInt32(e.Item.Cells[0].Text,10); e.Item.Attributes.Add("onclick=this.style.backgroundColor","#f0f0f0"); e.Item.Attributes.Add("onclick","<script> alert('"+itemIndex+"')</script>"); } this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; 楼主说的是Web的,还是winForm的啊?winForm中设置属性:DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;Web中楼上给了 this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;dataGridView1 的属性里面有设置直接设置就完了 关于c#类的使用请教! C#操作Excel,懂Excel也可以进来看下。 如何利用委托关闭窗体、释放资源? 如何用C#调用VBA6.DLL里的EbExecuteLine方法? 用代码打开wav声音文件 如何传送自定义消息 怎么样在winform上实现象证券交易所大屏那样显示数据的功能?? 大家知不知道有没有C#的视频教材啊??? 如何在C#中调用扫描仪来存储相片 如何选择gridview中某行的值 急 小妹初学C#,我在SQL里建了一个存储过程,程序调用的时候查询结果都是错的,急死了!向大家请教请教!
{
if(e.Item.ItemIndex==-1) return;
e.Item.Attributes.Add("style","cursor:hand");
e.Item.Attributes.Add("onMouseOver=this.style.backgroundColor","#add8ef");
e.Item.Attributes.Add("onMouseOut=this.style.backgroundColor","");
}
你试一下,我做的比较简单!
没发完
int itemIndex=e.Item.ItemIndex;
itemIndex=Convert.ToInt32(e.Item.Cells[0].Text,10);
e.Item.Attributes.Add("onclick=this.style.backgroundColor","#f0f0f0");
e.Item.Attributes.Add("onclick","<script> alert('"+itemIndex+"')</script>");
}
DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;Web中楼上给了
dataGridView1 的属性里面有设置
直接设置就完了