CF 1.0 SP3 - WinCE - FullScreen and Controls.Clear() - Add()

G

Guest

Hi
I'm developping a WinCE 5.0 app using VS 2003, C# and CF 2.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 !!!!!!

As you see I've tried everithing I know (visible, invalidate, refresh etc
etc) but I allways get the same behaviour.

Do you khnow how I can get the right behaviour ?

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 help

Ciao
Marco
 
G

Guest

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 post if you know the right solution...is there a bug in the
invalidate() or refresh method ?

Ciao
Marco
 

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