Datagrid in Designer

S

Stanley

I have a control that I have built a custom designer that shows the content
from an ItemTemplate. However the Datagrid never shows up in the designer.
It seems at this point that the Datagrid is the only thing that will not
show up in the designer for me and this is an issue for me because it will
throw off the layout. Now the Datagrid does show up at run-time perfectly
fine. But I need it to show up in the designer. Is there something I am
missing?

Basically to make things show up from the item template I do:

Code:
'If the ItemTemplate is defined, use it
If Not _itemTemplate Is Nothing Then
Dim itemContainer As New Panel
_itemTemplate.InstantiateIn(itemContainer)
itemContainer.ID = "ItemTemplate1"

'Add the item to the table
c.Controls.Add(itemContainer)
End If

c is actually a HTMLTableCell and then I use TextWriter to output the end
results of my objects in the designer. But as I said the Datagrid does not
show up.

TIA

-Stanley
 
A

Alessandro Zifiglio

I dont see your template, plus you are using _itemTemplate.InstantiateIn()
function and passing it a panel control.
You should be passing your template here. I have no idea what you are doing
at this point, so what i'm going to do is post all the steps you need to
take to implement a tempate in your custom control. As for the designer
issue, you need to associate your control with a ControlDeisgner. Because
you are using templates have this class inherit from
TemplatedControlDesigner(This is a long step) Look for the "Templated
data-bound Control designer sample" sample in the docs or MSDN.

Private _itemTemplate as itemplate = nothing


<Bindable(False), Browsable(False), _
PersistenceMode(PersistenceMode.InnerProperty), _
Description("The content to be shown in each item."), _
TemplateContainer(GetType(MyItemTemplate))> _
Public Property ItemTemplate() As ITemplate
Get
Return _ItemTemplate
End Get
Set(ByVal Value As ITemplate)
_ItemTemplate = Value
End Set
End Property



If Not (_ItemTemplate Is Nothing) Then
Dim item As New MyItemTemplate()
'Now the Control object to contain the instantiated controls from the
inline template
ItemTemplate.InstantiateIn(item.Cells(0))
'Now add the row to your table.
table.Rows.Add(item)
End If





'Now MyTemplate Container class --note this class has been
'associated to your template(ItemTemplate)
'in the property you exposed in your control above.

Public Class MyItemTemplate : Inherits TableRow
Implements INamingContainer
Public Sub New()
Cells.Add(New TableCell())
End Sub
End Class
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,214
Latest member
JFrancisDavis

Latest Threads

Top