473,473 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagridcell paint problem

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

Jul 21 '05 #1
2 1594
Why don't you try overriding the PaintText() method instead..

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
jinu wrote:
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

Jul 21 '05 #2

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...
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tamir Khason | last post by:
How to prevent the selected cell from being editable (visual) at DataGrid? Once click on cell (even readonly) there are cursor inside it and select text appears. How to prevent it Thankx
2
by: Rene | last post by:
Currently, the paint even will only acknowledge painting going on inside of the ClipRectangle, any of the drawing that is outside of the ClipRectangle is ignored. How can I get the paint...
0
by: vooose | last post by:
Consider a UserControl to which you do userControl.Paint += new PaintEventHandler(paint_method) If you don't like that way, and prefer to override onPaint( ) then the problem stated below...
3
by: Mike Cooper | last post by:
I have been staring at the above error for over a week now! I have a an inherited data class looking like thus: Public Class DataGridBoolColumnInherit Inherits...
3
by: DraguVaso | last post by:
Hi, I'm able to set the Font in a Datagrid-Cell to Bold with g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString, e.TextFont, e.ForeBrush, bounds.X, bounds.Y) and to Align the text...
2
by: jinu | last post by:
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...
1
by: Karl | last post by:
Hi there, I have a problem needs help. In a winform, I have a datagrid. In Mouse move event, I can get coodinates of Mouse. I want to decide which datagridcell my mouse is on. Can anybody...
7
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other...
5
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, On a usercontrol I've put a set of radiobuttons within a groupbox. These radiobuttons have visual style enables, i.e. they turn orange when hovering over them and green when pushed. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.