We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to highlight the particular cell position on VerticalScrollbar?

Platform: WinForms |
Control: GridControl

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

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile