dataGridView中如何使添加的button不可用?还有如何使第一列值为1的行的背景色为红色?并且单击button弹出message,在线等,急!! 如题,我的dataGridView有2列id、button控件,我想使id>4的行的button不可用,id为1的行的背景色为红色,并且单击button弹出message,怎么做?请高手帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用循环..首先判断选中的该列 if(int.parse(DATAGRIDVIEW.SELECTRow[0].index)>4){ 后面的你知道该怎么弄了吧? BUTTON.ENALBE=false;//不可用状态.} 上面好像有点错,不好意思啊 我以为你是要>4行以后的 你先获得该列 判断是否大于4 和上面一样 获得方法. dataGridView1.CurrentRow.Cells[索引/字段].Value.ToString().Trim(); 按钮用事件. 背景颜色.. 获得该字段.BACKCOLOR=COLOR.颜色; http://msdn.microsoft.com/zh-cn/worldwide/ms171619.aspx#Mtps_DropDownFilterText 设置红色for (int i = 0; i < dataGridView1.Rows.Count; i++) { int v = int.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()); if(v == 1) dataGridView1.Rows[i].Cells[0].Style.BackColor = Color.Red; } 触发DataGridViewButtonColumn的响应事件private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) //写在CellClick事件里面{ if (e.ColumnIndex == dataGridView1.Columns["Button"].Index) //"Button"是DataGridViewButtonColumn列的名字 MessageBox.Show(e.RowIndex.ToString()); } 将一个六万行的dataTable导入到Access中 求 最快方法... c# winfrom 用户控件的属性为何无法改变,有解决办法吗? 字符串可以反射成自定义的类的类型吗? 加密解密问题。。。 rss功能如何实现 调用API中的DeleteService来删除Windows服务时,服务总是标识已禁用,关掉我的程序,删除的服务就消失了 如何用C#实现在程序里直接将当前所用的域用户设置为本机管理员 _weikun_(Virus)进来接分 简单送分问题,,在线等!! VS6时代用过匈牙利命名法的请进 DataGridview数据绑定有什么作用? 字段类型疑问?help me!
首先判断选中的该列
if(int.parse(DATAGRIDVIEW.SELECTRow[0].index)>4)
{
后面的你知道该怎么弄了吧?
BUTTON.ENALBE=false;//不可用状态.
}
我以为你是要>4行以后的
你先获得该列 判断是否大于4
和上面一样
获得方法.
dataGridView1.CurrentRow.Cells[索引/字段].Value.ToString().Trim();
背景颜色..
获得该字段.BACKCOLOR=COLOR.颜色;
{
int v = int.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
if(v == 1)
dataGridView1.Rows[i].Cells[0].Style.BackColor = Color.Red;
}
{
if (e.ColumnIndex == dataGridView1.Columns["Button"].Index) //"Button"是DataGridViewButtonColumn列的名字
MessageBox.Show(e.RowIndex.ToString());
}