473,382 Members | 1,576 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,382 software developers and data experts.

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 2331
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.