Need more help on UserControl

L

Lau Lei Cheong

Hello,

I'm writing a usercontrol that contains a property named "disabled". It
is set to false by default but there is also another button in the
usercontrol that'll set it to true.

On the main form a number of them are displayed. During the On_Load
event, 1) It'll check to see if the usercontrol is disabled. If true, the
row containing the usercontrol is hidden.

2) If all these usercontrols are disabled, the main form will redirect the
user to another form.

Here is my problem: Although I've successfully implemented (1) by
directly invoke "parent.visible = false" in the disablebutton_click event, I
couldn't find way to do checking (2) that won't let the usercontrol directly
call methods in the main form.

If I do the checking (2) in Form_load() of the main form, the form won't
redirect until a second refresh so a blank page will be displayed. Seems
that I have to put the code in other event but I have no idea. Can anyone
suggest what I should do to fix it?

Any help would be appreciated.

Regards,
Lau Lei Cheong
 
C

Cowboy

Slap a panel on the user control and set it to Visible = false. You can then
set the enabled property to allow the panel to be shown. This is the easiest
method, considering the architecture you describe.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
L

Lau Lei Cheong

Perheps there's something to clarify.

I have no problem hiding the controls(that is 1) but I have problem
redirecting the page to a new URL if all control is hid(that is 2 and is
what I want to ask).

I found that I cannot check for the redirection in Form_Load because it
seems the events of main form will run earlier then the usercontrol's
event.(while I thought the control.click event will always be earlier than
the Form_Loads...)
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top