Groups | Blog | Home
all groups > dotnet windows forms designtime > june 2007 >

dotnet windows forms designtime : Designtime behaviour of a tabcontrol in a usercontrol


Johnny Kühne
6/1/2007 6:26:02 AM
Hello Newsgroup

I'm working with VS 2005 Prof. on a usercontrol, which should look like a
wizzard.

In this usercontrol I have tabcontrol, which should be active in designtime,
so a user can drag other controls on it.
I have achieved this behaviour with a ParentControlDesigner for the
usercontrol and a call of EnableDesignMode für the tabcontrol and each
tabpage.

With a Smart Tag I add new tabpages to the tabcontrol. If I do so, the
usercontrol does not save this pages in the designer file (or any other
controls on this page). Because of that, the usercontrol looses the controls
when reopen the Form. But if I use the Smart Tag of the tabcontrol, the new
pages are stored in the designer file.

Does somebody knows what could be wrong?

Thank you for your answers!
Bryan Phillips
6/2/2007 2:30:11 PM
Have you looked at applying the DesignerSerialization attribute to the
property for the tab collection?

--
Bryan Phillips
MCT, MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
Web Site: http://www.composablesystems.net



[quoted text, click to view]
Johnny Kühne
6/3/2007 7:51:06 AM
Hi Bryan

Thank you for your answer.
Yes, I tested with "content" and "visible" for the control.

Greetings

[quoted text, click to view]
Johnny Kühne
6/3/2007 10:27:00 AM
Hi Newsgroup

I finally found the answer on:
http://www.developerfusion.co.uk/show/4665/6/

I simply had added a new tabpage to the control, but I should have used the
CreateComponent method of IDesignerHost:


Dim h As IDesignerHost =
DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
Dim dt As DesignerTransaction = Nothing
Dim c As IComponentChangeService =
DirectCast(GetService(GetType(IComponentChangeService)),
IComponentChangeService)

'Add a new tabpage to the collection
Dim t As TabPage = Nothing
dt = h.CreateTransaction("Add Step")
t = DirectCast(h.CreateComponent(GetType(TabPage)), TabPage)
t.Text = Replace(Me.jkw.strText_StepTitle, "%nr%",
Me.jkw.tabPages.TabCount)
c.OnComponentChanging(Me.jkw, Nothing)
Me.jkw.tabPages.TabPages.Add(t)
c.OnComponentChanged(Me.jkw, Nothing, Nothing, Nothing)
Me.jkw.tabPages.SelectedIndex = Me.jkw.tabPages.TabCount - 1
dt.Commit()

Thank you for your help Brian.

Greetings Johnny

[quoted text, click to view]
AddThis Social Bookmark Button