Sizer for WinForms

Splitter Color

Tagged: ,

  •  nianios said 11 months ago:

    Hi,

    I have read :
    http://our.componentone.com/groups/winforms/sizer-for-winforms/forum/topic/50114
    and
    http://our.componentone.com/samples/winforms-customsplitters
    but I cannot put color in my splitters:
    I have tried:
    On paint event:

     Private Sub szer1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles szer1.Paint
         
                'Create Brush
                Dim redBrush As Brush = Brushes.Red
                    
                For i = 0 To szer1.Grid.Rows.Count – 1
                  Dim r As C1.Win.C1Sizer.Row = szer1.Grid.Rows(i)
                  'draw grip area
                  Dim rc As Rectangle = szer1.Grid.Rows(i).Bounds
                  rc.Y = rc.Bottom
                  rc.Height = szer1.Grid.Rows(i + 1).Bounds.Y – rc.Y
                  e.Graphics.FillRectangle(redBrush, rc)
                Next
             End Sub
    

    and with my Sub:

    Private Sub szer1Repaint(sender As System.Object, e As PaintEventArgs)
    
            Dim redBrush As Brush = Brushes.Red
    
            For i = 0 To szer1.Grid.Rows.Count – 1
                Dim r As C1.Win.C1Sizer.Row = szer1.Grid.Rows(i)
                'draw grip area
                Dim rc As Rectangle = szer1.Grid.Rows(i).Bounds
                rc.Y = rc.Bottom
                rc.Height = szer1.Grid.Rows(i + 1).Bounds.Y – rc.Y
                e.Graphics.FillRectangle(redBrush, rc)
            Next
        End Sub

    I tried also this:

    Private Sub szer1Repaint(sender As System.Object, e As PaintEventArgs)
           Dim redPen As Pen = Pens.Red
            For i = 0 To szer1.Grid.Rows.Count – 1
                For j = 0 To szer1.Grid.Columns.Count – 1
                  Dim rc As Rectangle = szer1.GetCellBounds(i, j)
                  e.Graphics.DrawRectangle(redPen, rc)
               Next
            Next
        End Sub

    Nothing happened.
    Could you please help?

  •  richas14p said 11 months ago:

    Hello Nianios,

    Please use the following code for changing the row splitter color :

        Private Sub C1Sizer1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles C1Sizer1.Paint
            'Create Brush
            Dim redBrush As Brush = Brushes.Red
    
              For i As Integer = 0 To C1Sizer1.Grid.Rows.Count – 2
                Dim r As C1.Win.C1Sizer.Row = C1Sizer1.Grid.Rows(i)
                Dim rc As Rectangle = C1Sizer1.Grid.Rows(i).Bounds
                rc.Y = rc.Bottom
                rc.Height = C1Sizer1.Grid.Rows(i + 1).Bounds.Y – rc.Y
                e.Graphics.FillRectangle(redBrush, rc)
            Next
    
        End Sub

    Thanks,
    Richa

    Answer
  •  nianios said 11 months ago:

    I tried this, but unfortunately it paints only the splitters of the rows and not of the columns
    I add this code and it works:

           For i As Integer = 0 To C1Sizer1.Grid.Columns.Count – 2
                Dim r As C1.Win.C1Sizer.Column = C1Sizer1.Grid.Columns(i)
                Dim rc As Rectangle = C1Sizer1.Grid.Columns(i).Bounds
                rc.X = rc.Right
                rc.Width = tlp1.Grid.Columns(i + 1).Bounds.X – rc.X
                e.Graphics.FillRectangle(redBrush, rc)
            Next
    

    Thanks

  •  richas14p said 11 months ago:

    Hello Nianios,

    As I mentioned earlier, the above works for Rows only. For painting the columns, your code is required.

    Thanks,
    Richa

  •  nianios said 11 months ago:

    You are right
    Thanks for your help

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.