Articles in this section

How to highlight the particular cell position on VerticalScrollbar in WinForms GridControl?

In order to highlight the particular cell position in the vertical scrollbar, the Paint event can be used. The position should be calculated as per the code below.


// Highlight the current cell position.
this.scrollersFrame1.VerticalScroller.Paint += VerticalScroller_Paint;

void VerticalScroller_Paint(object sender, PaintEventArgs e)
{
   height = this.gridControl1.DefaultRowHeight * rowIndex;
   y = height < view ? 0 : (height / view);
   y = y * (view / part);
   y = y + (height % view)/part;
   DrawRect(e.ClipRectangle);            
}

  //Draw the rectangle on the vertical scroll bar.
private void DrawRect(Rectangle rect)
{     
   renderer.rect = new Rectangle(rect.X, y, rect.Width, 3);
}
'Highlight the current cell position.
AddHandler Me.scrollersFrame1.VerticalScroller.Paint, AddressOf VerticalScroller_Paint

Private Sub VerticalScroller_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
   height_Renamed = Me.gridControl1.DefaultRowHeight * rowIndex
   y = If(height_Renamed < view, 0, (height_Renamed / view))
   y = y * (view \ part)
   y = y + (height_Renamed Mod view)/part
   DrawRect(e.ClipRectangle)
End Sub

'Draw the rectangle on vertical scroll bar. 
Private Sub DrawRect(ByVal rect As Rectangle)
   renderer.rect = New Rectangle(rect.X, y, rect.Width, 3)
End Sub

The screenshot below illustrates highlighting the current row position by using the vertical scrollbar.


Graphical user interface, application, table, Excel


Sample Links

C#: Current Row_Position_CS

VB: Current Row_Position_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied