We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,725 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

user control in C#.net

hi,

i am creatnig an windows desktop application. and in the main form i have a menu stript. what i want to do is attached one user control to eacn menu stript. each user control has a different design.
how can i do this???
any tutorial

2
Contributors
2
Replies
17 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
judithSampathwa
Posting Pro in Training
453 posts since May 2010
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

Judith, you asked a similar question in this thread.
What effect are you trying to achieve?
[Edit]
What do you mean by "attach one user control to each menu strip"?

nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 188
Skill Endorsements: 3

Have you looked at using a ToolStrip instead.
This allows you to "host" any control derived from Control.
A detailed example can be found here.

This is what I came up with to use a PictureBox in a ToolStripMenu.

public partial class Form2 : Form
	{
		ToolStripPictureBox toolstripPictureBox;
		public Form2()
		{
			InitializeComponent(); //<- toolStip1 added by designer
			toolstripPictureBox = new ToolStripPictureBox();
			toolstripPictureBox.PictureBoxImage = this.Icon.ToBitmap();
			toolStrip1.Items.Add(toolstripPictureBox);
		}
	}

	class ToolStripPictureBox : ToolStripControlHost
	{
		public ToolStripPictureBox()
			: base(new PictureBox())
		{
		}

		public PictureBox PictureBoxControl
		{
			get { return this.Control as PictureBox; }
		}

		public Image PictureBoxImage
		{
			get { return PictureBoxControl.Image; }
			set { PictureBoxControl.Image = value; }
		}
	}
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 188
Skill Endorsements: 3

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0603 seconds using 2.67MB