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()
{
InitializeCompo nent();
this.textBox1.T ext = val1.ToString() ;
}
public void set_val(double i)
{
val1 = i;
}
}
/////////Parent usercontorl's code/////////////
public partial class ParentUC : UserControl
{
public ParentUC()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
this.childUC1.s et_val(1000);
}
}
///////////// MainForm has deualt code --- no change to original
designer code////////////
------------------------Sample Code end------------------------------- 2 2350
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()
{
InitializeCompo nent();
this.textBox1.T ext = val1.ToString() ;
}
public void set_val(double i)
{
val1 = i;
this.textBox1.T ext = 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() { InitializeCompo nent(); this.textBox1.T ext = val1.ToString() ; } public void set_val(double i) { val1 = i; } } /////////Parent usercontorl's code///////////// public partial class ParentUC : UserControl { public ParentUC() { InitializeCompo nent(); }
private void button1_Click(o bject sender, EventArgs e) { this.childUC1.s et_val(1000); } } ///////////// MainForm has deualt code --- no change to original designer code////////////
------------------------Sample Code end-------------------------------
Thanks Mark.
It works fine
oldfark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 reduced my form request to a simple text string
entry, instead of my desired optional parameters. As i have been stuck
with a single unfathomable glitch for over a year.
Basically, if i enter queries such as ;
"select * from table" "select * from...
|
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* and use it to load an texture
from some outside functions. My problem lies in the "for loop", the Code
goes as follows.
//I create the array of pointers, I'm using 2 just for the sake of an
example
MapTextures = new unsigned int;
|
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 accounts be setup - if so are there any
specific requirements to be aware of.
Does this eliminate user locking?
Are there any other specific requirements necessary before users enter
data?
Many thanks in advance for any advice received.
|
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 page. This works ok on it's own but I
can't seem to access the actual value of the control or the option value
( <option value="6">...NT...</option>)
..
Any ideas ppl?
|
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 right now, I save schedule.ascx
as another name, say schedule2.ascx then I go to code behind and chane the
class name and the methods I like to change. Also modify the UI on ascx
file.
This is working. But there is a problem, evertime I change...
| |
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 variable
then i write a property to get or set the value of that private integer
variable.
But with the above method i can'nt get that property.
|
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 the server and the web page loads the control via the <object> tag.
I have also added a iexplore.exe.config file (because of another thread) where I specify that .net v1.1 should be used. (The controls have been developed in VS2003) I have also...
|
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 in it, but when i try to modify the value and exit / lost focus from the user control the value did'nt change, it agains shows the initial value (i.e the value from the data already in the user control when the FORM loads)
How can i modify the...
|
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 there is break point in app,otherwise not).Any one knows why so?I tried to give time delay,by inserting for loop,bt it does'nt worked.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |