Dynamic DataGridView missing horizontal scrollbar

C

Crazy Cat

Hi,

I am dynamically creating datagridviews for my application, then
filling them with data from a 30 row datatable, and everything seems to
work great with one exception. My horizontal scrollbar never appears --
no problem with the vertical scrollbar. I even try setting the
scrollbars property to Both, but still I only see the vertical
scrollbar.

Is there any other way to force the DataGridView's vertical scrollbar
to appear?????

Thanks,

Crazy
 
V

Vijay

Try selecting the last cell of the grid row... using code... that might help

Vijay
 
C

Crazy Cat

Vijay said:
Try selecting the last cell of the grid row... using code... that might help

Vijay

Doesn't work -- I used datagridview.currentrow.cells(INDEX).selected =
true but no dice.

Any other ideas?

Thanks
 
V

Vijay

uhm.. ok.., And you do have more than the visible area of columns, still not
getting scrollbars.. are u using 2.0 or 1.1 ?

VJ
 
C

Cor Ligthert [MVP]

Crazy,

With this code I see a vertical and a horizontal scrollbar

\\\
Dim mydatagridview As New DataGridView
Controls.Add(mydatagridview)
mydatagridview.DataSource = MyEmployeesBindingSource
///

I hope this helps,

Cor
 
C

Crazy Cat

I'm pretty sure I'm using 2.0. I do have more than the visible area of
columns -- almost twice as much.

Thanks,
 
C

Crazy Cat

I don't have a binding source because I don't use the DataSet designer
to get the tables back. Perhaps that'll help? I'll take a look and post
back.

Thanks,
 
C

Crazy Cat

OK,

I tried this again with the Binding Source and still no scrollbar --
does anyone have any other ideas???? PLEASE???

Here's the code --


Dim tabDetails As TabPage
Dim DetailsBindingSource As BindingSource
Dim dgvDetails As DataGridView

tctlDetails.TabPages.Clear()
If PortDetailsDataSet IsNot Nothing Then
For Each dt As System.Data.DataTable In
PortDetailsDataSet.Tables

Me.tctlDetails.TabPages.Add(dt.Rows(0).Item("MSC_NAME"))
tabDetails =
tctlDetails.TabPages(tctlDetails.TabPages.Count - 1)
dgvDetails = New DataGridView()
With dgvDetails
.Visible = True
.AllowUserToAddRows = False
.AllowUserToDeleteRows = False
DetailsBindingSource = New
BindingSource(PortDetailsDataSet, dt.TableName)
.DataSource = DetailsBindingSource
tabDetails.Controls.Add(dgvDetails)
dgvDetails.Dock = DockStyle.Fill
dgvDetails.ScrollBars =
System.Windows.Forms.ScrollBars.Both
For Each a As DataGridViewColumn In .Columns
a.ReadOnly = True
Next
.ScrollBars = System.Windows.Forms.ScrollBars.Both
End With
Next
End If

BTW, on a side note I allow the user to clear the tabs from the
tabcontrol assuming that because the dynamic bindingsources and
datatables are no longer referenced the VS garbage collecter will clean
them up. Is that a correct assumption or should I delete the referenced
objects myself?

Thanks,

Crazy
 
C

Cor Ligthert [MVP]

Crazy Cat,

Because that I see "Dock Fill" are you sure that your DataGridView is narrow
enough to show the horizontal scrollbar?

Cor
 
C

Crazy Cat

Cor said:
Crazy Cat,

Because that I see "Dock Fill" are you sure that your DataGridView is narrow
enough to show the horizontal scrollbar?

It should be, even when the application is maximized I can only see
about 50 - 60 % of the columns.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top