RE: Design Time support for custom columns in DataGridView (VS 2005)
- From: v-jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Wed, 10 Aug 2005 06:33:00 GMT
Hi robrich,
Thanks for your post.
Yes, the sample code for the article "Host Controls in Windows Forms
DataGridView Cells" is missed in that link. Fortunately, in
forums.microsoft.com, a Microsoft PM has posted up the sample code, you may
get it from the link:
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=66954
For the design-time support issue, yes, Whidbey has complete different
editor for DataGridView. If we use Reflector to view DataGridView.Columns
property, we can see that its default editor is:
System.Windows.Forms.Design.DataGridViewColumnCollectionEditor.
Then, in "public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)" of
DataGridViewColumnCollectionEditor class, it just constructs a
DataGridViewColumnCollectionDialog for editing the columns collection.
In DataGridViewColumnCollectionDialog.addButton_Click method(which is
triggered when we clicked the add button on the editor form), designer will
popup another form to add new column, that is: DataGridViewAddColumnDialog
Then, in DataGridViewAddColumnDialog constructor, we should find
PopulateColumnTypesCombo() method calling to be interesting. Yes, actually,
it takes the responsibility for populating the column type combobox.
At last, we see that in PopulateColumnTypesCombo() method, the code below
get a collection of types, which is used for filling the combobox:
service1.GetTypes(DataGridViewAddColumnDialog.dataGridViewColumnType,
false)); //service1 is of type: ITypeDiscoveryService
If we look in the Whidbey MSDN document below for
ITypeDiscoveryService.GetTypes() method:
http://msdn2.microsoft.com/library/ssy78ba2(en-us,vs.80).aspx
We see that:
"If baseType is null, all types are returned. Otherwise, only types derived
from the specified base type are returned. If excludeGlobalTypes is false,
types from all referenced assemblies are checked. Otherwise, only types
from non-Global Assembly Cache (GAC) referenced assemblies are checked."
So, if we add our customized column into the current project, VS.net
design-time will successfully query this and display our column type in the
combobox for user to select(because our customized column is a child type
of DataGridViewAddColumnDialog.dataGridViewColumnType).
I have tried the sample code in
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=66954, the
CalendarColumn will appear in the combobox successfully.
Hope this helps.
============================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.
- Follow-Ups:
- References:
- Prev by Date: Design Time support for custom columns in DataGridView (VS 2005)
- Next by Date: Component Licensing at Design Time
- Previous by thread: Design Time support for custom columns in DataGridView (VS 2005)
- Next by thread: RE: Design Time support for custom columns in DataGridView (VS 200
- Index(es):