Search code examples
c#vb.netwinformsgridviewscrollbar

Remove or hide the vertical scrollbar in GridView WinForms


I have an application on WinForms for POS client. My client have a touch screen system so i need to implement buttons to scroll in GridView.

Now i am facing the problem is that i am unable to hide the scrollbar. When i tried to hide scroll bar a black splitted image appear

If TypeOf (sender) Is VScrollBar Then
                Dim scrollBar As VScrollBar = CType(sender, VScrollBar)
                If TypeOf (scrollBar.Parent) Is KryptonExtendedGrid Then
                    Dim KryptonGrid As KryptonExtendedGrid = CType(scrollBar.Parent, KryptonExtendedGrid)
                    If KryptonGrid.ScrollControl IsNot Nothing Then
                        If scrollBar.Visible Then
                            grdForecast.ScrollBars = ScrollBars.None
                            scrollBar.Visible = False
                            scrollBar.Hide()
                            KryptonGrid.ScrollControl.DownButton.Enabled = True
                        Else
                            KryptonGrid.ScrollControl.DownButton.Enabled = False
                        End If
                    End If
                End If
            End If

enter image description here

enter image description here


Solution

  • Thanks all for you kind support. I have fix it by myself. I am sharing the code in case any one need help

    Private Sub VScrollBar1_VisibleChanged(ByVal sender As Object, ByVal e As EventArgs)
            Try
                If TypeOf (sender) Is VScrollBar Then
                    Dim scrollBar As VScrollBar = CType(sender, VScrollBar)
                    If TypeOf (scrollBar.Parent) Is KryptonExtendedGrid Then
                        Dim KryptonGrid As KryptonExtendedGrid = CType(scrollBar.Parent, KryptonExtendedGrid)
                        If KryptonGrid.ScrollControl IsNot Nothing Then
                            If KryptonGrid.ScrollBars = ScrollBars.Vertical  Then
                                KryptonGrid.ScrollBars = ScrollBars.None
                                KryptonGrid.ScrollControl.DownButton.Enabled = True
                            Else
                                KryptonGrid.ScrollControl.DownButton.Enabled = False
                            End If
                        End If
                    End If
                End If
            Catch ex As Exception
    
            End Try
        End Sub