all groups > dotnet windows forms databinding > january 2005 >
You're in the

dotnet windows forms databinding

group:

Data checking during databinding


Data checking during databinding EMW
1/10/2005 2:53:03 AM
dotnet windows forms databinding:
Hi,

Is it possible to check the data just before it is bound to a datagrid?
I.e. I have a large table of numbers which I bind to a datagrid.
What I want to do is to check for each cell what the value of the number is
and do something to the color of that cell if that value is lower, inbetween
or higher then a specific value.

is this possible or would it slow down the databinding too much?

--
rg,
Re: Data checking during databinding Ritesh Jain via DotNetMonster.com
1/11/2005 7:18:53 AM
Hi,
There is one way u can get what u want....................
steps
1>Create ur own custome class which inherits from DataGridTextBoxColumn
2>Declare one Public Event which will be raised by Paint Event......

3>Overrides the Paint Event of DataGridTextBoxColumn and in that u raise the above event which will be exposed to the class or form where u r using Grid. as shown below........

public event CheckCellValue as u r Type

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)

RaiseEvent CheckCellValue(Me,e) 'where e is ur Argument Type

if e.Condition =True then
backBrush = Brushes.LightGray
end if
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)

End sub

4>In that event check for the Value of the Current Cell and Accordingly set the Argument of the Event Handler..................


I hope u r getting what i am trying to explain..........

Regards,
Ritesh

--
AddThis Social Bookmark Button