Winform DataGridView 里面设置了字体的样式,可是每点击一下DataGridView 上的内容,当前单元格的字体颜色就加深,有什么办法解决? RT,谢谢!datagridviewwinform字体 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议你用css样式来做,它只是客户关颜色变化,与服务器无关设置两个样式:onmousemove="OnMouseOver_DataRow(this)"onmouseout="OnMouseOut_DataRow(this)" 通过设置OnmouseOver事件来设置为原来颜色 是WinForm窗体应用程序 WinForm同样有MouseEnter事件的啊 仔细多看几次 msdn保证可以解决 dataGridView1.Rows[1].Cells[1].Style.ForeColor = System.Drawing.Color.Red没有发现加深问题啊 在后台绑定前设置 dataGridView1.DefaultCellStyle.ForeColor = System.Drawing.Color.Red; BackColor ForeColorSelectionBackColor SelectionForeColor说明你的SelectionForeColor比ForeColor颜色深 先将datagridview选中的背景颜色去掉。在CellContentClick事件用一个count计数,点击一次计一次。 然后根据count来改变字体颜色。前提判断选中的是否跟上一次匹配。这样能行? 21楼是正解,我没有设置ForeColor的背景颜色。我用你的代码没有变颜色,可能是因为我在编辑列的时候就设置了DefaultCellStyle。感觉DataGridView有好多问题需要注意喔。 解决办法在这里,楼主不要纠结了:1.设置DataGridView的SelectionMode属性为DataGridViewSelectionMode.FullRowSelect;2.实现DataGridView的CellFormatting事件,在其单元格格式发生变化时响应;3.实现如下:void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e){ DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; //设置想要的样式,这里只设置字体样式,当前选中行黑体加粗,否则普通文本 if (row.Selected) row.DefaultCellStyle.Font = new Font("黑体",12f,FontStyle.Bold); else row.DefaultCellStyle.Font = new Font(Font, FontStyle.Regular);}其余的当前选中行颜色什么的可以简单设置如下属性:dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White;dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Red; 怎样清掉datagridview选中的背景颜色去掉?这个我没有写过。 CellClick 让选中的单元格颜色跟没选中的一样 不就行了嘛 [讨论]什么时候使用静态方法最合适 C#构造函数设计 让SQL企业管理器加密通过代码怎样实现? 关于点击 button, 自动添加物体的问题,谢谢。 C#.net怎么实现代码刷新 回收站文件的处理 200分请教一个打印的问题…… Web水晶报表(V10.0)不预览直接打印如何实现? 新手求完善程序 求助:用asp.net(c#)开发用户界面 图片上传查看下载桌面应用(网络版)开发设计思路咨询 如何获得默认打印机的名字?
onmousemove="OnMouseOver_DataRow(this)"
onmouseout="OnMouseOut_DataRow(this)"
没有发现加深问题啊
SelectionBackColor SelectionForeColor
说明你的SelectionForeColor比ForeColor颜色深
在CellContentClick事件用一个count计数,
点击一次计一次。 然后根据count来改变字体颜色。
前提判断选中的是否跟上一次匹配。这样能行?
1.设置DataGridView的SelectionMode属性为DataGridViewSelectionMode.FullRowSelect;
2.实现DataGridView的CellFormatting事件,在其单元格格式发生变化时响应;
3.实现如下:void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
//设置想要的样式,这里只设置字体样式,当前选中行黑体加粗,否则普通文本
if (row.Selected)
row.DefaultCellStyle.Font = new Font("黑体",12f,FontStyle.Bold);
else
row.DefaultCellStyle.Font = new Font(Font, FontStyle.Regular);
}其余的当前选中行颜色什么的可以简单设置如下属性:
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White;
dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Red;