一段代码不理解e.PaintParts

dalianliyan 2010-09-18 05:27:39

Private Sub DataGridView1_RowPrePaint(ByVal sender As Object, _
ByVal e As DataGridViewRowPrePaintEventArgs) _
Handles DataGridView1.RowPrePaint
'背景を描画するか

If (e.PaintParts And DataGridViewPaintParts.Background) = _
DataGridViewPaintParts.Background Then
'選択されているか調べ、色を決定する
'bColor1が開始色、bColor2が終了色
Dim bColor1, bColor2 As System.Drawing.Color
If (e.PaintParts And DataGridViewPaintParts.SelectionBackground) = _
DataGridViewPaintParts.SelectionBackground AndAlso _
(e.State And DataGridViewElementStates.Selected) = _
DataGridViewElementStates.Selected Then
bColor1 = e.InheritedRowStyle.SelectionBackColor
bColor2 = System.Drawing.Color.Black
Else
bColor1 = e.InheritedRowStyle.BackColor
bColor2 = System.Drawing.Color.YellowGreen
End If
‘还有一些代码
End If
End Sub


其中的(e.PaintParts And DataGridViewPaintParts.Background) = DataGridViewPaintParts.Background
这句和下面的一句不太明白,谁能帮忙解释一下呢
这个and起的什么作用,为什么不能直接写等号
...全文
46 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dalianliyan 2010-09-18
  • 打赏
  • 举报
回复
明白了 谢谢
看来是我对and运算的理解不够深入啊
兔子-顾问 2010-09-18
  • 打赏
  • 举报
回复
比如
dim a as byte = 1
dim b as byte = 3
1转成2进制形式表示
0000 0001
3转成2进制形式表示
0000 0011
那么
a and b
结果就是 1
就是2进制形式中,相同的位保留。
兔子-顾问 2010-09-18
  • 打赏
  • 举报
回复
位操作,两个变量"与"操作。

16,554

社区成员

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

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