what control to use

T

Tarscher

Hi all,

I have an application that has a form (MainForm) with a tabcontrol. I
want to populate the tabs (3 tabs) with other controls. I prefer to
put those controls (3 controls) in different classes since this allows
me to break up the UI in functional parts.

Momentarily I'm using usercontrols on each tab but this has it's
issues. Mainly the MainForm designer doesn't work anymore since I pass
parameters to the constructors of the usercontrols.

Someone can advice me another control?

Thanks
Stijn
 
B

Bob Powell [MVP]

Don't pass parameters in the constructor of a user control and create
properties for your user controls that are used instead. In this manner
the properties may even be set at design time.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
T

Tarscher

Don't pass parameters in the constructor of a user control and create
properties for your user controls that are used instead. In this manner
the properties may even be set at design time.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consultinghttp://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Trickshttp://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQhttp://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

Thanks for the fast reply.

I don't quite understand "create properties for your user controls
that are used instead". My user controls need a cennctionstring. The
connection string is stored in the app.config. How do I get the
connectionstring in the user control?

thanks
 
S

Simon Harvey

Tarscher said:
Thanks for the fast reply.

I don't quite understand "create properties for your user controls
that are used instead". My user controls need a cennctionstring. The
connection string is stored in the app.config. How do I get the
connectionstring in the user control?

thanks

Do something like:

class MyControl{
private string connectionString = null;

// Property Accessor

public string ConnectionString{
get{
return connectionString;
}
set{
connectionString = value;
}

}

// Note - no params
public MyControl(){

}
}
 

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

Top