datagridview选定问题

想飞的狼 2008-09-04 02:13:49
简单问题,datagridview的selectionmode有cellselect,如何在我选定某个单元格时使整行的背景色为绿色呢?如果用FULLROWSELECT选择整行会是一个颜色,可却不能复制某个单元格,只能复制一行,请高手帮忙
...全文
101 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jacksom 2008-09-20
  • 打赏
  • 举报
回复
利用5楼的把这个sz定为类的全局变量就行了。
想飞的狼 2008-09-15
  • 打赏
  • 举报
回复
哈哈,自己整明白了,
想飞的狼 2008-09-15
  • 打赏
  • 举报
回复
????????
想飞的狼 2008-09-15
  • 打赏
  • 举报
回复
为什么我把以下代码放到cellenter或rowenter里时所有行全变色呢?
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

If sz = -1 Then

DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor = Color.DodgerBlue

sz = DataGridView1.CurrentCell.RowIndex
Me.Text = sz
Else
DataGridView1.Rows(sz).DefaultCellStyle.BackColor = Color.GhostWhite
DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor = Color.DodgerBlue

sz = DataGridView1.CurrentCell.RowIndex
End If

End Sub


想飞的狼 2008-09-06
  • 打赏
  • 举报
回复
ddddddddddddddddd
cauhorse 2008-09-06
  • 打赏
  • 举报
回复
换个别的触发事件试试。。
想飞的狼 2008-09-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 limeng0513 的回复:]
大概的思路就是
DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor =
其他行颜色复位
[/Quote]

大侠的语名没问题可以解决问题,可是为什么当我点击速度快时就会出现有的单元格已经单击了,可是整行还是未变色呢
   Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

If sz = -1 Then

DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor = Color.DodgerBlue

sz = DataGridView1.CurrentCell.RowIndex
Me.Text = sz
Else
DataGridView1.Rows(sz).DefaultCellStyle.BackColor = Color.GhostWhite
DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor = Color.DodgerBlue

sz = DataGridView1.CurrentCell.RowIndex
End If

End Sub
想飞的狼 2008-09-05
  • 打赏
  • 举报
回复
???
duzhonghua 2008-09-04
  • 打赏
  • 举报
回复
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting


e.CellStyle.BackColor = Color.DarkGray
破咖啡罐子 2008-09-04
  • 打赏
  • 举报
回复
大概的思路就是
DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.BackColor =
其他行颜色复位
想飞的狼 2008-09-04
  • 打赏
  • 举报
回复
d

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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