473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Child usercontrol contained parent user control does'nt redisplay

HI All..
I'm realtively new to C#.

I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.

MainForm --> Parent usercontrol --> child usercontrol

Parent usercontol has one button to change the child usercontorl's
variable.
Child usercontrol has one textbox that display child usercontrol's
variable.

When I press button of parent usercontrol, I change the variabe of
child user control, and I want to display the variable to textbox.
But textbox does not change its value.

What kind of action do I need?
Any suggestion would be greatly appreciated.

oldfark

-----------------Sample Code start----------------
/////////Child usercontorl's code////////////////
public partial class ChildUC : UserControl
{
double val1=0;

public ChildUC()
{
InitializeComponent();
this.textBox1.Text = val1.ToString();
}
public void set_val(double i)
{
val1 = i;
}
}
/////////Parent usercontorl's code/////////////
public partial class ParentUC : UserControl
{
public ParentUC()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
this.childUC1.set_val(1000);
}
}
///////////// MainForm has deualt code --- no change to original
designer code////////////

------------------------Sample Code end-------------------------------

Jan 27 '06 #1
2 2336
Hi lotus,
in your set_val method you are assigning the new value to a variable, but
you are not updating the value of the Text property of the textbox which
controls what is displayed in the textbox, you just need to add one more line:

public partial class ChildUC : UserControl
{
double val1=0;

public ChildUC()
{
InitializeComponent();
this.textBox1.Text = val1.ToString();
}
public void set_val(double i)
{
val1 = i;
this.textBox1.Text = val1.ToString();
}
}
Hope that helps
Mark Dawson
http://www.markdawson.org

"lotus" wrote:
HI All..
I'm realtively new to C#.

I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.

MainForm --> Parent usercontrol --> child usercontrol

Parent usercontol has one button to change the child usercontorl's
variable.
Child usercontrol has one textbox that display child usercontrol's
variable.

When I press button of parent usercontrol, I change the variabe of
child user control, and I want to display the variable to textbox.
But textbox does not change its value.

What kind of action do I need?
Any suggestion would be greatly appreciated.

oldfark

-----------------Sample Code start----------------
/////////Child usercontorl's code////////////////
public partial class ChildUC : UserControl
{
double val1=0;

public ChildUC()
{
InitializeComponent();
this.textBox1.Text = val1.ToString();
}
public void set_val(double i)
{
val1 = i;
}
}
/////////Parent usercontorl's code/////////////
public partial class ParentUC : UserControl
{
public ParentUC()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
this.childUC1.set_val(1000);
}
}
///////////// MainForm has deualt code --- no change to original
designer code////////////

------------------------Sample Code end-------------------------------

Jan 27 '06 #2
Thanks Mark.

It works fine

oldfark

Jan 27 '06 #3

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

Similar topics

23
5641
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
10
2295
by: Nick L | last post by:
I'm working on a function which creates a pointers to an array of unsigned ints based off a number read from a file. I then continue to read file names from the file, convert the name to a char*...
1
3819
by: Heather | last post by:
Advice greatly appreciated in in finalising setup for data entry : After splitting mdb should an MDE be stored on each local workstation and the data stored on the server? Should individual user...
4
1378
by: Moe Sizlak | last post by:
Hi There, I am trying to use the to obtain the information from 2 listmenus, if the user makes a selection the page is submitted and then based on the value selected is transfererd to another...
1
1340
by: Danny Ni | last post by:
Hi, I have one user control named Schedule.ascx, I want to create another control which is quite similar to schedule.ascx but differs in some methods and some UI elements, the way I am doing it...
1
1657
by: Jamil | last post by:
Hello, I am loading the user control daynamically using Page.LoadControl('mycontrol.ascx"). But with this i can not get my datamember's properties. For example i declare a private integer...
0
1694
by: AndySummers | last post by:
Hi We have just re-written a majour asp.net project to use a user control embedded in a web page. The main dll references 3 other custom controls and so to deploy the project I copy the 4 dll's to...
0
1115
by: bijuvarghese576 | last post by:
I made a user control in which i used a textbox which accepts only numeric only. I tested and it is working fine. I used this user control in my FORM and bound it with a data field, it shows value...
3
1585
by: suvarna1026 | last post by:
Hi,I got traped about an unknown error. I have made HttpUpload Component(OCX) in VB6.0.It is working fine only when I give break point in my application(I mean I can upload file on server only when...
0
7225
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
7124
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
7326
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
7498
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
5629
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,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.