Hello
VS 2003.
I am trying to hide some columns in a datagrid. The datagrid is bound to a typed dataset data source.
This is the code I have used to set the column width to zero. However, as there are many columns to hide I get left with a bold black line where the column should have been. So the customer doesn't want to see this. This is the code I used, just wondering is there a better way to do this.
Many thanks,
Steve
VS 2003.
I am trying to hide some columns in a datagrid. The datagrid is bound to a typed dataset data source.
This is the code I have used to set the column width to zero. However, as there are many columns to hide I get left with a bold black line where the column should have been. So the customer doesn't want to see this. This is the code I used, just wondering is there a better way to do this.
Many thanks,
Steve
Code:
//GridTableStylesCollection grdTblSty = new GridTableStylesCollection();
DataGridTableStyle tblStyle = new DataGridTableStyle();
tblStyle.MappingName = "OrderDetail";
grdBeverages.TableStyles.Add(tblStyle);
grdBeverages.DataSource = DS.OrderDetail.DefaultView;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["OrderDetailID"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["BeverageID"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["Beverage"].Width = 50;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["BeverageQty"].Width = 40;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["BeverageQty"].HeaderText = "Qty";
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["BeverageCost"].Width = 40;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["BeverageCost"].HeaderText = "Cost";
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["StarterID"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["Starter"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["StarterQty"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["StarterCost"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["MaincourseID"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["Maincourse"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["MaincourseQty"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["MaincourseCost"].Width = 0;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["TotalCost"].Width = 40;
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["totalCost"].HeaderText = "Cost";
grdBeverages.TableStyles["OrderDetail"].GridColumnStyles["OrderID"].Width = 0;