'Author : Syed Shanu
'Company : Telstar-Hommel
'Date : 2007-06-22
'Description :This Class is created for Datagrid column back color change when datagrid load this class will triger and draw the color to specific datagrid coumn
Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Namespace ThetaMLA
Public Class DataGridEnableTextBoxColumn
Inherits DataGridTextBoxColumn
Private _col As Integer
'Fields
'Constructors
'Events
'Methods
Public Delegate Sub EnableCellEventHandler(ByVal sender As Object, ByVal e As DataGridEnableEventArgs)
Public Sub New(ByVal column As Integer)
MyBase.New()
_col = column
End Sub
Public Event CheckCellEnabled As EnableCellEventHandler
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
'can remove this if you don't want to vary the color of diabled cells
Dim enabled As Boolean
enabled = True
Dim e As DataGridEnableEventArgs
e = New DataGridEnableEventArgs(rowNum, _col, enabled)
RaiseEvent CheckCellEnabled(Me, e)
If Not (e.EnableValue) Then
backBrush = Brushes.Gainsboro 'LightGray 'System.Drawing.Color.FromArgb(137, 164, 218) 'Brushes.Silver
'Else
'' backBrush = Brushes.Goldenrod
End If
'end of coloring code
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
Dim enabled As Boolean
enabled = True
Dim e As DataGridEnableEventArgs
e = New DataGridEnableEventArgs(rowNum, _col, enabled)
RaiseEvent CheckCellEnabled(Me, e)
If e.EnableValue Then
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
End If
End Sub
End Class
End Namespace