datagridview column headers don't show

  • Thread starter Thread starter Rick
  • Start date Start date
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
 
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
 
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.
 
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.
 
Back
Top