VS.NET Intellisense Support for Exposing DataGridColumnCollection in a UserControl

O

olliecwl

Hi,

I have a UserControl that contains an AJAX.NET UpdatePanel wrapped
around a DataGrid. I'm exposing the datagrid's column collection as a
public property of the UserControl. It looks something like this:

[
Browsable(true),
PersistenceMode(PersistenceMode.InnerProperty),
]
public DataGridColumnCollection Columns
{
get { return InnerGrid.Columns; }
}

When used on a page, the UserControl looks something like this:

<my:CopyGrid ID="CopyTheseItems" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate><b><%# Container.DataItem %></b></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</my:CopyGrid>

This functions as I'd hoped.

The problem is in the building of the page. When creating the
UserControl on a page, I get the option to add a Columns inner
property tag. However, once inside that tag, I get NO Intellisense
support for the various DataGridColumn objects. For whatever reason,
it reverts back to the generic UI editor, giving me support for the
creation of labels, textboxes, panels, etc.

So after perusing the boards, I found and tried this:

public class MyDataGridColumnCollectionEditor : CollectionEditor
{
public MyDataGridColumnCollectionEditor(Type type) : base(type) { }

protected override Type CreateCollectionItemType()
{ return typeof(DataGridColumn); }

protected override Type[] CreateNewItemTypes()
{
Type[] types = new Type[] { typeof(TemplateColumn),
typeof(BoundColumn), typeof(ButtonColumn),
typeof(DataGridColumn), typeof(HyperLinkColumn)
};
return types;
}

protected override object CreateInstance(Type itemType)
{
DataGridColumn column =
itemType.GetConstructor(Type.EmptyTypes).Invoke(null) as
DataGridColumn;
return column;
}
}

......

[
Browsable(true),
PersistenceMode(PersistenceMode.InnerProperty),
EditorAttribute(typeof(MyDataGridColumnCollectionEditor),typeof(System.Drawing.Design.UITypeEditor)),
]
public DataGridColumnCollection Columns
{ ... }

No luck. I also took a look at (and considered revising) the .XSD
files backing VS.NET, but that's a hornets' nest I'd rather avoid if I
can.

So... any thoughts? Like I wrote above, the UserControl works as I'd
hoped; the problem I'm having is developing with it in an efficient
and intuitive manner.

Your thoughts are appreciated.

best,
jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top