Datagridcell paint problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jinu

    #1

    Datagridcell paint problem

    In a vb.net application, we are using the DataGridColored TextBoxColumn class
    which is derived from DataGridTextBox Column 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.GetColumnVal ueAtRow(source, rowNum)
    If (Not (obj) Is Nothing) Then
    If Me.HeaderText = "Prod." Then
    Format = "N0"
    foreBrush = New SolidBrush(Colo r.RoyalBlue)
    alignToRight = True
    End If
    End If
    Finally
    MyBase.Paint(gr p, 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,4 5 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



  • Sijin Joseph

    #2
    Re: Datagridcell paint problem

    Why don't you try overriding the PaintText() method instead..

    Sijin Joseph




    jinu wrote:[color=blue]
    > In a vb.net application, we are using the DataGridColored TextBoxColumn class
    > which is derived from DataGridTextBox Column 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.GetColumnVal ueAtRow(source, rowNum)
    > If (Not (obj) Is Nothing) Then
    > If Me.HeaderText = "Prod." Then
    > Format = "N0"
    > foreBrush = New SolidBrush(Colo r.RoyalBlue)
    > alignToRight = True
    > End If
    > End If
    > Finally
    > MyBase.Paint(gr p, 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,4 5 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
    >
    >
    >[/color]

    Comment

    • jinu

      #3
      Re: Datagridcell paint problem


      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...


      Comment

      Working...