Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Temperature? Pin
Dave Kreskowiak6-Nov-04 2:26
mveDave Kreskowiak6-Nov-04 2:26 
GeneralRe: Temperature? Pin
bouli6-Nov-04 2:29
bouli6-Nov-04 2:29 
GeneralRe: Temperature? Pin
Dave Kreskowiak6-Nov-04 5:37
mveDave Kreskowiak6-Nov-04 5:37 
GeneralLinking into SQL's replication engine Pin
Zangarine5-Nov-04 11:13
Zangarine5-Nov-04 11:13 
GeneralRe: Linking into SQL's replication engine Pin
Alex Korchemniy5-Nov-04 15:31
Alex Korchemniy5-Nov-04 15:31 
GeneralRe: Linking into SQL's replication engine Pin
Zangarine5-Nov-04 20:50
Zangarine5-Nov-04 20:50 
GeneralRe: Linking into SQL's replication engine Pin
Dave Kreskowiak6-Nov-04 2:25
mveDave Kreskowiak6-Nov-04 2:25 
GeneralOnPaint problem Pin
Guinness4Strength5-Nov-04 11:11
Guinness4Strength5-Nov-04 11:11 
I am creating a UserControl that is a collection of Panles setup in a grid format. Each element of the grid is a Panel. I allow the user to add text to the panel in one of Nine locations described by the ContentAllingment Structure.

The Text object is nothing more than a Label control. I'm using a gradient brush to paint the background of each panel in the grid and am setting the background color or each Label control to transparent. My problem is on the initial paintof the control, all the grid boxes are transparent until I move the window or resize the control. If I choose to not set the Label control's background property to transparent, then all the Panels get painted correctly, but the Label controls llok bad because they have a flat backgournd color while it's parent Panel gas a gradient background color. My question is, why would nothing be getting painted until the control is resized or moved.
Here is the OnPaint handler override
protected override void OnPaint(PaintEventArgs e)
{
	try
	{
		//paint the background
		LinearGradientBrush brush;
		brush = new LinearGradientBrush(
			ClientRectangle.Location,
			new Point(ClientRectangle.Left,ClientRectangle.Bottom),
			this.BackColor, 
			ControlPaint.Light(this.BackColor));
		e.Graphics.FillRectangle(brush, ClientRectangle);
		brush.Dispose();

		//add labels here
		foreach(PanelLabel PL in LabelArray)
		{
			PanelLabel lb=null;
			bool LabelFound=false;
			foreach(Control ctrl in this.Controls)
			{	
				if(ctrl is PanelLabel)
				{
					lb = (PanelLabel)ctrl;
					if(lb!=null)
					{
						ContentAlignment CA = (ContentAlignment)lb.SimpleLocation;
						if(lb.Text==PL.Text && CA==PL.SimpleLocation)
						{
							LabelFound=true;
							break;
						}
					}
				}
				else
					continue;
			}
			if(!LabelFound)
			{
				lb = new PanelLabel();
				lb.Font=new Font(lb.Font,PL.TextStyle);
				lb.Text=PL.Text;
				lb.SimpleLocation=PL.SimpleLocation;
				lb.BackColor=Color.Transparent;//comment out this line allows painting
			}
			lb.Bounds=SetLabelLocation(lb,PL.SimpleLocation,e.Graphics);
			if(lb.Bounds!=Rectangle.Empty && lb.Bounds!=ClientRectangle)
				this.Controls.Add(lb);
			else 
				throw new Exception("Label bounds are empty");
		}
		base.OnPaint (e);
	}
	catch(Exception Err)
	{
		MessageBox.Show("On Paint Error:"+Err.Message);
	}
}


Any ideas are appreciated
GeneralRe: OnPaint problem Pin
Palladino6-Nov-04 2:44
Palladino6-Nov-04 2:44 
General(DR["Name"] is DBNull) vs (DR["Name"] == DBNull.Value) Pin
krisp5-Nov-04 8:24
krisp5-Nov-04 8:24 
GeneralRe: (DR["Name"] is DBNull) vs (DR["Name"] == DBNull.Value) Pin
Dave Kreskowiak5-Nov-04 9:51
mveDave Kreskowiak5-Nov-04 9:51 
Generalsearch about space in staring Pin
webhay5-Nov-04 8:01
webhay5-Nov-04 8:01 
GeneralRe: search about space in staring Pin
Charlie Williams5-Nov-04 8:35
Charlie Williams5-Nov-04 8:35 
Questiondrag-drop How? Pin
ben25-Nov-04 7:31
ben25-Nov-04 7:31 
AnswerRe: drag-drop How? Pin
Alex Korchemniy5-Nov-04 14:55
Alex Korchemniy5-Nov-04 14:55 
Generalapp resolution Pin
Agent 865-Nov-04 7:17
Agent 865-Nov-04 7:17 
GeneralRe: app resolution Pin
Alex Korchemniy5-Nov-04 14:45
Alex Korchemniy5-Nov-04 14:45 
Generalmonitoring a DCOM server Pin
Kevin Tambascio5-Nov-04 7:11
Kevin Tambascio5-Nov-04 7:11 
GeneralProgram don't stopps at Breakpoint Pin
Johannes Oehl5-Nov-04 4:29
Johannes Oehl5-Nov-04 4:29 
GeneralRe: Program don't stopps at Breakpoint Pin
Alex Korchemniy5-Nov-04 14:35
Alex Korchemniy5-Nov-04 14:35 
GeneralRe: Program don't stopps at Breakpoint Pin
Peff6-Nov-04 18:23
Peff6-Nov-04 18:23 
GeneralRe: Program don't stopps at Breakpoint Pin
Johannes Oehl10-Nov-04 21:26
Johannes Oehl10-Nov-04 21:26 
GeneralWeb Service Proxy class Pin
Member 5343575-Nov-04 4:25
Member 5343575-Nov-04 4:25 
GeneralRe: Web Service Proxy class Pin
Alex Korchemniy5-Nov-04 14:32
Alex Korchemniy5-Nov-04 14:32 
GeneralRe: Web Service Proxy class Pin
Member 5343578-Nov-04 2:53
Member 5343578-Nov-04 2:53 

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.