社区
C#
帖子详情
Winform Datagrid 中怎样将某一格改变颜色?
linforever
2003-08-20 12:52:56
比如,我要求点击某一格,就能将该格置为红色,可能实现吗?我现在能够解决通过hittest获取点击,那位能够帮我写出关键的代码,谢谢了
...全文
32
3
打赏
收藏
Winform Datagrid 中怎样将某一格改变颜色?
比如,我要求点击某一格,就能将该格置为红色,可能实现吗?我现在能够解决通过hittest获取点击,那位能够帮我写出关键的代码,谢谢了
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
greenhill1
2003-08-20
打赏
举报
回复
private void grd班级_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); 选择点击的行
}
int CellNu=dataGrid1.CurrentCell.RowNumber;//获得选中的行号
//在这里根据获得的行号选定你的datagrid行改变其backcolor值
}
linforever
2003-08-20
打赏
举报
回复
谢谢,可是这好像是web的datagrid啊,我需要的是winform的
csharplove
2003-08-20
打赏
举报
回复
private void InitializeComponent()中加事件:
this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
再定义函数定义:
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
e.Item.Attributes.Add("onmouseover","this.bgColor='oldlace'");
e.Item.Attributes.Add("onmouseout","this.bgColor='#ffffff'");
//e.Item.Attributes["onclick"] = "javascript:clickItem('ID" + e.Item.ItemIndex.ToString() + "');";
}
asp.net知识库
页面一postback,它就显示页面的最顶端,怎样让它定位在某一位置? 如何保证页面刷新后的滚动条位置 清除网页历史记录,屏蔽后退按钮! 如何传值在2个页面之间 :要求不刷新父页面,并且不能用Querystring传值 Asp...
Winform
:
dataGrid
View
中
让某一单元格不可以编辑、修改背景
颜色
单元格禁止编辑
winform
_
DataGrid
View_根据条件
改变
颜色
//整行
颜色
//dgvClass.Rows[e.RowIndex].Cells["开课时期"].Style.ForeColor = Color.Red;//单元格
颜色
} else if (Period == "2019年秋季班") { dgvClass.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color....
datagrid
(
winform
)使用指导
在网上收集的一些代码 一、增加COMBOBOX列: //在网格控件
中
增加一列为下拉列表框
DataGrid
TableStyle dgdtblStyle = new
DataGrid
TableStyle(); dgdtblStyle.MappingName = dtlList.TableName;
dataGrid
In....
DataGrid
单元格失去焦点时该行背景色
改变
<
DataGrid
.Resources> <Style TargetType="
DataGrid
Cell"> <Style.Triggers> <Trigger Property="
DataGrid
Cell.IsSelected" Value="true"> ...
C#
110,532
社区成员
642,574
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章