473,412 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Need more help on UserControl

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
Nov 18 '05 #1
2 1230
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!
************************************************
"Lau Lei Cheong" <la****@yahoo.com.hk> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2
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...)

"Cowboy" <No************@comcast.netNoSpamM> ¦b¶l¥ó
news:OL**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
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!
************************************************
"Lau Lei Cheong" <la****@yahoo.com.hk> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
2
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol...
15
by: Tee | last post by:
Hi, I have a base usercontrol with a method (blank method, no code), I have another few usercontrols that will inherit this base usercontrol, but I want to force all the usercontrol that...
0
by: krishnan | last post by:
Hi all I have a custom usercontrol in my window form "frmsett.cs" . "initializecomponents" of "frmsett.cs" initialises usercontrol This usercontrol is derived from a base component class....
1
by: Philipp Lenz | last post by:
I'm very confused about how this works, all the tutorials out there show me how to apply a skin to a webcontrol, but I want to know how I can access the components of a control....for example: I...
6
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the...
1
by: moondaddy | last post by:
I have a c# 3.5 wpf app which uses user controls for data entry screens. These data entry screens can be nested inside of each. We can also have several ones open side by side at the same time. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.