-
Nov 3rd, 2018, 10:09 AM
#1
Thread Starter
New Member
How to make visible the scrollbar of a datagridview that starts without data?
Hello, I had programmed a button to call a database access as follows:
Principal
Code:
Private Sub VerTablaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VerTablaToolStripMenuItem.Click
Code:
Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= data\Frg.accdb;Persist Security Info=False")
Dim da As New OleDbDataAdapter("SELECT * FROM Tabla1 ", cnn)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.ScrollBars = ScrollBars.Both ' example but not working
Now I understand that the code shows the database to datagridview1, but it turns out that in columns I have an approximate of 9 columns, now when I run the program it shows some horizontal data that are 5 that I can see on the screen and Worst of all is that I do not see the scrollbar or scrollbar,
under the previous code I had placed this
preview access
preview VB.NET
-
Nov 3rd, 2018, 08:48 PM
#2
Re: How to make visible the scrollbar of a datagridview that starts without data?
You can customize your DGV, but I don't think that's the problem in this case. Here's how...
Code:
Public Class CustomDgv
Inherits DataGridView
Private Const CAPTIONHEIGHT As Integer = 21
Private Const BORDERWIDTH As Integer = 1
Public Sub New()
' make scrollbars visible & add handler
Try
VerticalScrollBar.Visible = True
HorizontalScrollBar.Visible = True
Catch
End Try
AddHandler VerticalScrollBar.VisibleChanged, AddressOf ShowVScrollBar
AddHandler HorizontalScrollBar.VisibleChanged, AddressOf ShowHScrollBar
End Sub
Private Sub ShowVScrollBar(ByVal sender As Object, ByVal e As EventArgs)
Try
If Not VerticalScrollBar.Visible Then
Dim width As Integer = VerticalScrollBar.Width
VerticalScrollBar.Location = New Point(ClientRectangle.Width - width - BORDERWIDTH, 1)
VerticalScrollBar.Size = New Size(width, ClientRectangle.Height - HorizontalScrollBar.Height - BORDERWIDTH - 1)
VerticalScrollBar.Show()
End If
Catch
End Try
End Sub
Private Sub ShowHScrollBar(ByVal sender As Object, ByVal e As EventArgs)
Try
If Not HorizontalScrollBar.Visible Then
HorizontalScrollBar.Location = New Point(1, VerticalScrollBar.Bottom - BORDERWIDTH + 1)
HorizontalScrollBar.Size = New Size(ClientRectangle.Width - VerticalScrollBar.Width - 2, HorizontalScrollBar.Height)
HorizontalScrollBar.Show()
End If
Catch
End Try
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 3rd, 2018, 09:54 PM
#3
Re: How to make visible the scrollbar of a datagridview that starts without data?
Your question doesn't make much sense. Are you saying that the scrollbars don't appear even when there's data that requires scrolling? If so, don't you think that showing a screenshot of that instead of those other two might have been useful? If that's not what you're saying, what are you saying?
-
Nov 4th, 2018, 11:00 AM
#4
Thread Starter
New Member
Re: How to make visible the scrollbar of a datagridview that starts without data?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|