|
Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Public Class DataGridColoredTextBoxColumn
Inherits DataGridTextBoxColumn
Private HighLightColor As Color = Color.FromArgb(255, 255, 0)
Public Sub New()
End Sub
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)
Try
Dim o As Object = Me.GetColumnValueAtRow(source, rowNum)
If (Not (o) Is Nothing) Then
Dim c As String
If IsDBNull(o) Then o = ""
If TypeOf (o) Is VirtualDir Then
c = CType(o, VirtualDir).ToString()
Else
c = CType(o, String)
End If
If SearchString <> "" AndAlso c.ToLower().IndexOf(SearchString.ToLower()) >= 0 Then
backBrush = New SolidBrush(HighLightColor)
End If
End If
Finally
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
End Try
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I was born in 1970.
My first computer experience dates back to early 80s, with a Sinclair ZX81.
From that time on, as many "friends" say, my IT-illness has increased year by year.
I graduated in Electronic Engineering and earned the following Microsoft certifications:
MCP, MCT, MCDBA, MCSD, MCAD, MCSD for .NET (early achiever).
I worked in IT as a developer, a teacher, a consultant, a technical writer, a technical leader.
IT knowledge applied to real life is my primary interest and focus.