datagrid点击显示整行被选中

wxmwy 2007-01-13 08:14:37
我在datagrid控件里显示一个表的信息,我想实现电击其中一个字段,则该字段对应的整行都显示被选中颜色,这个用代码怎么实现。
...全文
543 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
奋斗男人 2007-01-15
  • 打赏
  • 举报
回复
加个选择列.
jason_he_cn 2007-01-15
  • 打赏
  • 举报
回复
DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
qqqvera 2007-01-15
  • 打赏
  • 举报
回复
ONCLICK事件
peak_weng 2007-01-15
  • 打赏
  • 举报
回复
internal class DataGridNoActiveCellColumn:DataGridColoredTextBoxColumn//System.Windows.Forms.DataGridTextBoxColumn
{
//重载DataGridTextBoxColumn类的Edit 方法,以便点击DataGrid中的任一单元格都选中当前行
protected override void Edit(CurrencyManager source,int rowNum,Rectangle bounds,bool readOnly,
string instantText,bool cellIsVisible)
{
int SelectedRow=rowNum;
this.DataGridTableStyle.DataGrid.Select(SelectedRow);
}
}
jkali 2007-01-15
  • 打赏
  • 举报
回复
protected void dtgGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Header)
{
//鼠标移动到每项时颜色交替效果
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#F3F3F3';this.style.color='#8C4510'");
}
}


我这个是鼠标移动时候的颜色,同理我想你可以用来做选定的颜色。
wxmwy 2007-01-15
  • 打赏
  • 举报
回复
这个事件的代码怎么写??
cynthia103 2007-01-13
  • 打赏
  • 举报
回复
给行对象加个ONCLICK事件
具体怎么写的我忘了
以前项目里做过的
wxmwy 2007-01-13
  • 打赏
  • 举报
回复
我在datagrid控件里显示一个表的信息,我想实现点击其中一个字段,则该字段对应的整行都显示被选中颜色,这个用代码怎么实现。

110,565

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧