datagridview column headers don't show

R

Rick

I'm adding columns to a datagridview in code. When I run the program the
data is bound correctly, but none of the column headers show.

Can someone point out what obvious mistake I am making?

Tnx,
Rick

Dim x As Integer

With dgvLookupPO

x = .Columns.Add("colPONum", "PO no")

..Columns(x).DataPropertyName = "PONum"

..Columns(x).ValueType = GetType(System.Int32)

..Columns(x).Visible = True

x = .Columns.Add("colPODate", "PO date")

..Columns(x).DataPropertyName = "PO_Date"

..Columns(x).ValueType = GetType(System.DateTime)

x = .Columns.Add("colPOTotal", "Total")

..Columns(x).DataPropertyName = "Total"

..Columns(x).ValueType = GetType(System.Decimal)

..Columns(x).DefaultCellStyle.Format = "###,###,##0.00"

..Columns(x).DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight

x = .Columns.Add("colPOVendor", "Vendor")

..Columns(x).DataPropertyName = "Name"

..Columns(x).ValueType = GetType(System.String)

End With
 
R

Rick

found it!

The columns were being created, but they didn't show because I had the grid
set to "Fill" and there was a BindingNavagator at the top of the form that
hid the column headers.

This is definately an irritation that fill does not seem to work properly
when there are other docked controls on the form, unless I am doing it
wrong?

Rick
 
C

ClayB

Make sure you drop the NavigationControl onto your form before you
drop and dock the DataGridView. If you first drop and dock the
DataGridView, then the DockFill will fill the entire form (at this
point there is no knowledge of the navigationControl that has not been
dropped yet, so no space is allocated for it) so that when the
NavigationControl is later dropped on the form, it must sit over top
of the DataGirdView.

===============
Clay Burch
Syncfusion, Inc.
 
R

Rick

thanks, I worked around this by putting the dgv in a panel which I docked
"fill". This works also, but I like your solution better.
 

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