Datagridcell paint problem

G

Guest

In a vb.net application, we are using the DataGridColoredTextBoxColumn class
which is derived from DataGridTextBoxColumn class inorder to give additional
colouring features.
For aligning certain cell contents to right (since the values are numbers),
we are using the following code. (alignToRight = True)

Protected Overloads Overrides Sub Paint(ByVal grp 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 obj As Object
obj = Me.GetColumnValueAtRow(source, rowNum)
If (Not (obj) Is Nothing) Then
If Me.HeaderText = "Prod." Then
Format = "N0"
foreBrush = New SolidBrush(Color.RoyalBlue)
alignToRight = True
End If
End If
Finally
MyBase.Paint(grp, bounds, source, rowNum, backBrush, foreBrush,
alignToRight)
End Try
End Sub

The problem is
for eg: if the value in a particular cell is 1'222'333,45 ( thousand
seperator is " ' " and decimal seperator is " , ")
when the value is painted in the grid, it is showing as 222'333,45'1
but if we select that cell, the value is shown correctly.

Also if we use " . " or " , " as the thousand seperator, the value is
correctly shown.
Suppose if the value is increased as 1'222'333'444,45 then, it is showing as
333'444,45'222'1 (not exactly but just to show that the number is getting a
reverse tendecy)

Any help would be deeply appreciated.
Thanks in advance
 
G

Guest

It is ok if the colouring (back as well as fore) and text alignment in a
particular cell is possible. If you dont mind, can you code for this
requirement by overriding the paintText() method.

Thanks in advance...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top