CF 1.0 SP3 - WinCE - FullScreen and Controls.Clear() - Add()
-
Hi I'm developping a WinCE 5.0 app using VS 2003, C# and CF 1.0 SP3. I'm currently testing on the WinCE 4.1 Emulator but a quick check on the CE 5.0 Device confirmed the behaviour. I create a full screen Form setting:
ControlBox = False FormBorderStyle = None WindowState = Maximmized
I add 3 buttons (button1, button2, button3) and add the following :private void button1_Click(object sender, System.EventArgs e) { this.Controls.Clear(); } private void Form1_Click(object sender, System.EventArgs e) { this.Controls.Add(button1); this.Controls.Add(button2); this.Controls.Add(button3); this.Refresh(); // this.Invalidate(); // button1.Invalidate(); // button2.Invalidate(); // button3.Invalidate(); // this.Invalidate(); // button1.Visible = true; // button2.Visible = true; // button3.Visible = true; // button1.BringToFront(); // button2.BringToFront(); // button3.BringToFront(); }
As you see I clear the controls with the first button and then try to reasign the 2 controls to the form on the OnClick event of the form. Guess what happens ? No controls appear on the first clieck, button2 and button3 on the second click and all of them on the third click. But there's more: The controls don't show, but they are there: I click where I remeber the control was and I get the button.OnClick event !!!!!! :omg: :confused: As you see I've tried everithing I know (visible, invalidate, refresh etc etc) but I allways get the same behaviour. Do you know how I can get the right behaviour ? I found a workaround, but I'm still looking for the right solution. the workaround is:private void button1_ParentChanged(object sender, System.EventArgs e) { (sender as Control).Visible = ((sender as Control).Parent != null); }
So the buttons turn invisible after the Controls.Clear() and return visible after the Controls.Add(). Please note that this is just a TEST APP, the real app must asign dinamically the controls so Controls.Clear() and Controls.Add() MUST be used Please Note: if I don't set theFormBorderStyle = None
property then everything works perfectly !!! :wtf: :wtf: :wtf: Please help Ciao Marco -
Hi I'm developping a WinCE 5.0 app using VS 2003, C# and CF 1.0 SP3. I'm currently testing on the WinCE 4.1 Emulator but a quick check on the CE 5.0 Device confirmed the behaviour. I create a full screen Form setting:
ControlBox = False FormBorderStyle = None WindowState = Maximmized
I add 3 buttons (button1, button2, button3) and add the following :private void button1_Click(object sender, System.EventArgs e) { this.Controls.Clear(); } private void Form1_Click(object sender, System.EventArgs e) { this.Controls.Add(button1); this.Controls.Add(button2); this.Controls.Add(button3); this.Refresh(); // this.Invalidate(); // button1.Invalidate(); // button2.Invalidate(); // button3.Invalidate(); // this.Invalidate(); // button1.Visible = true; // button2.Visible = true; // button3.Visible = true; // button1.BringToFront(); // button2.BringToFront(); // button3.BringToFront(); }
As you see I clear the controls with the first button and then try to reasign the 2 controls to the form on the OnClick event of the form. Guess what happens ? No controls appear on the first clieck, button2 and button3 on the second click and all of them on the third click. But there's more: The controls don't show, but they are there: I click where I remeber the control was and I get the button.OnClick event !!!!!! :omg: :confused: As you see I've tried everithing I know (visible, invalidate, refresh etc etc) but I allways get the same behaviour. Do you know how I can get the right behaviour ? I found a workaround, but I'm still looking for the right solution. the workaround is:private void button1_ParentChanged(object sender, System.EventArgs e) { (sender as Control).Visible = ((sender as Control).Parent != null); }
So the buttons turn invisible after the Controls.Clear() and return visible after the Controls.Add(). Please note that this is just a TEST APP, the real app must asign dinamically the controls so Controls.Clear() and Controls.Add() MUST be used Please Note: if I don't set theFormBorderStyle = None
property then everything works perfectly !!! :wtf: :wtf: :wtf: Please help Ciao MarcoDid you tried to use 'new' : button1 = new System.Windows.Forms.Button() Another question: why do you clear them from their parent. You could set them invisible, setting them visible again shoudl work without problem. I can't test your code, because i've just got Windows CE 4.0. Ingo
-
Did you tried to use 'new' : button1 = new System.Windows.Forms.Button() Another question: why do you clear them from their parent. You could set them invisible, setting them visible again shoudl work without problem. I can't test your code, because i've just got Windows CE 4.0. Ingo
[quote] Did you tried to use 'new' : button1 = new System.Windows.Forms.Button() [/quote] I don't need to create a new button..it's already there, I just need to set it's parent. Visible works but I need to get 'em off the parent form completely Thanks for the effort ;)
-
[quote] Did you tried to use 'new' : button1 = new System.Windows.Forms.Button() [/quote] I don't need to create a new button..it's already there, I just need to set it's parent. Visible works but I need to get 'em off the parent form completely Thanks for the effort ;)