Articles in this section
Category / Section

How to highlight the particular cell position on VerticalScrollbar?

1 min read

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

Code Snippet

C#

// 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 vertical scroll bar.
private void DrawRect(Rectangle rect)
{     
   renderer.rect = new Rectangle(rect.X, y, rect.Width, 3);
}

 

VB

‘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

 

 

 

 

 

 

 

 

 

Screenshot

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)
Please sign in to leave a comment
Access denied
Access denied