Click here to Skip to main content
15,888,803 members
Home / Discussions / C#
   

C#

 
AnswerRe: notify icon Pin
CoderForEver2-Aug-09 8:06
CoderForEver2-Aug-09 8:06 
QuestionCustom user control Pin
Jon Henry2-Aug-09 1:45
Jon Henry2-Aug-09 1:45 
AnswerRe: Custom user control Pin
Super Lloyd2-Aug-09 2:38
Super Lloyd2-Aug-09 2:38 
GeneralRe: Custom user control Pin
Jon Henry2-Aug-09 2:46
Jon Henry2-Aug-09 2:46 
GeneralRe: Custom user control Pin
Super Lloyd2-Aug-09 2:54
Super Lloyd2-Aug-09 2:54 
GeneralRe: Custom user control Pin
Super Lloyd2-Aug-09 3:16
Super Lloyd2-Aug-09 3:16 
GeneralRe: Custom user control Pin
Jon Henry2-Aug-09 3:23
Jon Henry2-Aug-09 3:23 
GeneralRe: Custom user control Pin
Super Lloyd2-Aug-09 4:05
Super Lloyd2-Aug-09 4:05 
I'm sorry but I still don't get it, could you write some code?

If I would guess, I would say it looks like your control is like that:
	public class MyControl : Control<br />
	{<br />
		public MyControl()<br />
		{<br />
			var b = new Button();<br />
			b.Size = new Size(80, 40);<br />
			b.Controls.Add(new Label { Text = "L1", Bounds = new Rectangle(10, 10, 20, 20), BackColor = Color.Transparent });<br />
			b.Controls.Add(new Label { Text = "L2", Bounds = new Rectangle(50, 10, 20, 20), BackColor = Color.Transparent });<br />
<br />
			Controls.Add(b);<br />
			b.Click += new EventHandler(b_Click);<br />
		}<br />
<br />
		void b_Click(object sender, EventArgs e)<br />
		{<br />
			Console.WriteLine("Clicked");<br />
		}<br />
	}<br />


Well, and I'm still surprised you can click on the label at all!
Nothing happen when I click on the label, be it 1 or 100 times!
And it's not the way to handle button.


I decided to stop investigating this pointless undefined problem and thought I could show you what I would do instead.

I would define a control, which looks like a button, and display what I need!
Here you go:
class MyControl2 : Control<br />
{<br />
	public MyControl2()<br />
	{<br />
		PushButtonState = PushButtonState.Normal;<br />
		Size = new Size(100, 50);<br />
	}<br />
<br />
	protected override void OnClick(EventArgs e)<br />
	{<br />
		base.OnClick(e);<br />
		Console.WriteLine("Clicked");<br />
	}<br />
<br />
	public PushButtonState PushButtonState { get; private set; }<br />
<br />
	protected override void OnMouseDown(MouseEventArgs e)<br />
	{<br />
		base.OnMouseDown(e);<br />
		PushButtonState = PushButtonState.Pressed;<br />
		Invalidate();<br />
	}<br />
	protected override void OnMouseUp(MouseEventArgs e)<br />
	{<br />
		base.OnMouseUp(e);<br />
		PushButtonState = PushButtonState.Normal;<br />
		Invalidate();<br />
	}<br />
<br />
	protected override void OnPaint(PaintEventArgs e)<br />
	{<br />
		// button look<br />
		ButtonRenderer.DrawButton(e.Graphics, new Rectangle(0, 0, Width, Height), PushButtonState);<br />
<br />
		// draw your labels<br />
		e.Graphics.DrawString("Label1", Font, Brushes.Red, new PointF(10, 10));<br />
		e.Graphics.DrawString("Label2", Font, Brushes.Blue, new PointF(50, 10));<br />
	}<br />
}<br />


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

GeneralRe: Custom user control Pin
Jon Henry2-Aug-09 4:25
Jon Henry2-Aug-09 4:25 
QuestionLooking for a control Pin
reilak2-Aug-09 0:05
reilak2-Aug-09 0:05 
AnswerRe: Looking for a control Pin
0x3c02-Aug-09 0:43
0x3c02-Aug-09 0:43 
GeneralRe: Looking for a control Pin
reilak2-Aug-09 20:48
reilak2-Aug-09 20:48 
Generalanother way to work with this control? [modified] Pin
reilak2-Aug-09 23:00
reilak2-Aug-09 23:00 
GeneralRe: another way to work with this control? Pin
0x3c03-Aug-09 3:04
0x3c03-Aug-09 3:04 
QuestionWindow Coordinates?? Pin
Muammar©1-Aug-09 23:58
Muammar©1-Aug-09 23:58 
AnswerRe: Window Coordinates?? Pin
dan!sh 2-Aug-09 0:10
professional dan!sh 2-Aug-09 0:10 
GeneralRe: Window Coordinates?? Pin
Muammar©2-Aug-09 7:52
Muammar©2-Aug-09 7:52 
QuestionCall method in parent aspx page from user control Pin
Chazzysb1-Aug-09 23:04
Chazzysb1-Aug-09 23:04 
AnswerRe: Call method in parent aspx page from user control [ ASP.NET Question ] Pin
Abhijit Jana1-Aug-09 23:42
professionalAbhijit Jana1-Aug-09 23:42 
AnswerRe: Call method in parent aspx page from user control Pin
dan!sh 1-Aug-09 23:54
professional dan!sh 1-Aug-09 23:54 
GeneralRe: Call method in parent aspx page from user control Pin
Chazzysb2-Aug-09 0:37
Chazzysb2-Aug-09 0:37 
GeneralRe: Call method in parent aspx page from user control [modified] Pin
Chazzysb2-Aug-09 2:31
Chazzysb2-Aug-09 2:31 
QuestionHow do I check whether a user is in an Active Directory group when given its username and password Pin
Andrew_1-Aug-09 21:32
Andrew_1-Aug-09 21:32 
AnswerRe: How do I check whether a user is in an Active Directory group when given its username and password Pin
Abhijit Jana1-Aug-09 21:56
professionalAbhijit Jana1-Aug-09 21:56 
GeneralRe: How do I check whether a user is in an Active Directory group when given its username and password Pin
Andrew_1-Aug-09 22:13
Andrew_1-Aug-09 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.