Hi,
"bordsby" <bo*****@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
Situation:
I am using an OleDbDataAdapter to fill a DataSet's DataTable with data
from an Access database. The DataSet's DataTable is bound to a
DataGrid. After the OleDbDataAdapter.Fill method is called, the
DataGrid displays the column headings as the column names output from
the Access SQL query. I would like to change some of the styles for
certain columns in the DataGrid, so I first need to set the
DataGridColumnStyle.MappingName Property of each DataGridColumnStyle.
According to the .NET docs, "The MappingName property is usually set to
the ColumnName of a DataColumn."
Question:
What is the ColumnName Property of a DataColumn equal to when the
DataColumn is automatically created as a result of the
OleDbDataAdapter? Is it equal to the column heading string?
ColumnName is the name of the column as it appears in the query if you use
DataAdapter.
DataColumn:
- ColumnName : the name of the column as it appears in the query (if you
used DataAdapter)
- Caption : returns ColumnName unless it has been set to something else
If the DataGridColumnStyles are auto-generated then:
- MappingName = DataColumn.ColumnName
- HeaderText = DataColumn.ColumnName
so that's why the HeaderText in the grid is the same as the column names in
your query.
If you create the column styles yourself, then you have to set MappingName
and HeaderText yourself. MappingName should be set to one of the
DataColumn's ColumnName and HeaderText can be set to whatever you want.
HTH,
Greetings