Not sure what you mean there. The name of a component is determined by the INameCreationService, the class name is used and then a search is made up through the hierachy to find the next appropriate index. After that a name has been declared as simply as it can be done in the designer properties window. There is no real reason for MS to have just appended the field name retrieved from the database. That was the point i was trying to make. Having the type name of the component in the name property of a generated datacolumn seems a bit overkill, and serves no useful purpose from what i can see.
oh, i disagree. the two part name:
PreferredShippingModeDataGridViewComboBoxColumn
CustomerGenderDataGridViewComboBoxColumn
here lets us tell that both these are columns of our datagridview, they hold combobox types and so we can set combo specific properties on them. Additionally, because our datagrid has more than one column that is a combo type, they are named according to the semantic the user has chosen. We may want to make the shipping mode combo perform an auto complete if there are 20 shipping modes, but the male/female choice means autocomplete might not be necessary for such a small list. hence we can:
PreferredShippingModeDataGridViewComboBoxColumn.AutoComplete = true
CustomerGenderDataGridViewComboBoxColumn.AutoComplete = false
rather than having to guess or calculate which column index to which we wish to refer.
I'm puzzled about two lines of your post:
>There is no real reason for MS to have just appended the field name retrieved from the database
>Having the type name of the component in the name property of a generated datacolumn seems a bit overkill
I'm not sure which you find extraneous.. taking these statements alternately would you prefer these columns to be called:
(preserving field name, regressing type through hierarchy)
PreferredShippingModeDataGridViewComboBoxColumn
PreferredShippingModeDataGridViewColumn
PreferredShippingModeDataGridViewBand
PreferredShippingModeDataGridViewElement
PreferredShippingModeObject
(preserving type through regressing, dropping friendly name)
DataGridViewComboBoxColumn1
DataGridViewColumn1
DataGridViewBand1
DataGridViewElement1
Object1
(dropping both type name and friendly name)
1
(just using collections and casting)
DirectCast(...Columns("PreferredShippingMode"), DataGridViewComboBoxColumn)
DirectCast(...Columns(0), DataGridViewComboBoxColumn)
Personally, i'd take the typed property route of
PreferredShippingModeDataGridViewComboBoxColumn over
DirectCast(...Columns("PreferredShippingMode"), DataGridViewComboBoxColumn) any day
I must admit i normally prefix the type rather than suffix it:
cboPreferredShippingMode
chkAllowSaturdayDelivery
but some mention of both type and name is made in my variables declarations. Do you prefer to just use collection indexes and casting?