当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
09年计算机二级VB辅导:VB.net中根据内容改变datagridview单元格颜色
发布时间:2009/9/27 17:09:03 来源:城市学习网 编辑:admin
  1PrivateSubcustomerDataGridView_CellFormatting(ByValsenderAsObject,ByValeAsDataGridViewCellFormattingEventArgs)HandlescustomerDataGridView.CellFormatting
  2
  3  ’Ifthecolumnbeingformattedisthecolumnnamed’Status’..
  4  IfMe.customerDataGridView.Columns(e.ColumnIndex).Name="Status"Then
  5    Ife.ValueIsNotNothingThen
  6      ’Ifthevalueofthecellis"Inactive"ANDthisform’sinactiveCustomersCheckBoxcontrolischecked..
  7      Ife.Value.ToString="Inactive"AndMe.inactiveCustomersCheckBox.CheckedThen
  8        ’SettheBackColorofthecelltoyellow.
  9        e.CellStyle.BackColor=Color.Yellow
  10      EndIf
  11    EndIf
  12  EndIf
  13
  14  ’Ifthecolumnbeingformattedisthecolumnnamed’LastOrderDate’..
  15  IfMe.customerDataGridView.Columns(e.ColumnIndex).Name="LastOrderDate"Then
  16    Ife.ValueIsNotNothingThen
  17      ’IfLastOrderDatewasmorethan30daysagoANDthisform’sordersOverdueCheckBoxcontrolischecked..
  18      IfDate.Now.Subtract(CType(e.Value,Date)).Days>30AndMe.orderOverdueCheckBox.CheckedThen
  19        ’SettheBackColorofthecelltoyellow-green.
  20        e.CellStyle.BackColor=Color.YellowGreen
  21      EndIf
  22    EndIf
  23  EndIf
  24EndSub
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved