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

Using other class controls

After trying to solve thois bymyself i gave up. I was i visual basic 6
programmer, now i m getting to java and c#. The problem i have is simple, but
it seems to be a hell for me.

<EXPLANATION>

I' ve 2 forms, Form1 is one class and Form2 is another class. On form1 i've
a textbox (textBox1), and on form2 i've a button(button1). What i am trying
to do is when i press the button on form2 i want to change the value of the
textBox1 placed on form1.

<CODE>

On Form1 a do the following:

Form2 v_Form = new Form2();
v_Form.Show.

with that a create a new instance of Form2 and i show it then.
On Form2 i did the following:

private void button1_click(.....)
{
Form1.ControlCollection["textBox1"].text="Marco";
}
</CODE>

</EXPLANATION>

I've tryied many otrher ways, to remenber that i set the control (textBox1)
public in Form1.
Can you please help me on this.
Thank you
Me_Titus

Nov 16 '05 #1
4 2916
You need to set a reference to form1 on form2 to be able to access it

cheers,
mortb

"Me_Titus" <Me******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
After trying to solve thois bymyself i gave up. I was i visual basic 6
programmer, now i m getting to java and c#. The problem i have is simple,
but
it seems to be a hell for me.

<EXPLANATION>

I' ve 2 forms, Form1 is one class and Form2 is another class. On form1
i've
a textbox (textBox1), and on form2 i've a button(button1). What i am
trying
to do is when i press the button on form2 i want to change the value of
the
textBox1 placed on form1.

<CODE>

On Form1 a do the following:

Form2 v_Form = new Form2();
v_Form.Show.

with that a create a new instance of Form2 and i show it then.
On Form2 i did the following:

private void button1_click(.....)
{
Form1.ControlCollection["textBox1"].text="Marco";
}
</CODE>

</EXPLANATION>

I've tryied many otrher ways, to remenber that i set the control
(textBox1)
public in Form1.
Can you please help me on this.
Thank you
Me_Titus

Nov 16 '05 #2
But how do i do that, i've tryied everything i knew, could you show me the
light.
Thanks,
Me_Titus
"mortb" wrote:
You need to set a reference to form1 on form2 to be able to access it

cheers,
mortb

"Me_Titus" <Me******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
After trying to solve thois bymyself i gave up. I was i visual basic 6
programmer, now i m getting to java and c#. The problem i have is simple,
but
it seems to be a hell for me.

<EXPLANATION>

I' ve 2 forms, Form1 is one class and Form2 is another class. On form1
i've
a textbox (textBox1), and on form2 i've a button(button1). What i am
trying
to do is when i press the button on form2 i want to change the value of
the
textBox1 placed on form1.

<CODE>

On Form1 a do the following:

Form2 v_Form = new Form2();
v_Form.Show.

with that a create a new instance of Form2 and i show it then.
On Form2 i did the following:

private void button1_click(.....)
{
Form1.ControlCollection["textBox1"].text="Marco";
}
</CODE>

</EXPLANATION>

I've tryied many otrher ways, to remenber that i set the control
(textBox1)
public in Form1.
Can you please help me on this.
Thank you
Me_Titus


Nov 16 '05 #3
But how do i do that, i've tryied everything i knew, could you show me the
light.
Thanks,
Me_Titus
"mortb" wrote:
You need to set a reference to form1 on form2 to be able to access it

cheers,
mortb

"Me_Titus" <Me******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
After trying to solve thois bymyself i gave up. I was i visual basic 6
programmer, now i m getting to java and c#. The problem i have is simple,
but
it seems to be a hell for me.

<EXPLANATION>

I' ve 2 forms, Form1 is one class and Form2 is another class. On form1
i've
a textbox (textBox1), and on form2 i've a button(button1). What i am
trying
to do is when i press the button on form2 i want to change the value of
the
textBox1 placed on form1.

<CODE>

On Form1 a do the following:

Form2 v_Form = new Form2();
v_Form.Show.

with that a create a new instance of Form2 and i show it then.
On Form2 i did the following:

private void button1_click(.....)
{
Form1.ControlCollection["textBox1"].text="Marco";
}
</CODE>

</EXPLANATION>

I've tryied many otrher ways, to remenber that i set the control
(textBox1)
public in Form1.
Can you please help me on this.
Thank you
Me_Titus


Nov 16 '05 #4
Hope this helps,

public class Form2 : <inheritied stuff>
{
public Textbox refTxt1; // <-- add this line

..... all your other code ...

private void button1_click(.....)
{
refTxt1.text="Marco";
}
}

public class Form1: <inherited stuff>
{
private void MyMethod()
{
Form2 v_Form = new Form2();
v_Form.refTxt1 = Text1; // <-- add the reference to the text
box into form2's class
v_Form.Show.
}
}
--- Nick

"Me_Titus" <Me*****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
But how do i do that, i've tryied everything i knew, could you show me the
light.
Thanks,
Me_Titus
"mortb" wrote:
You need to set a reference to form1 on form2 to be able to access it

cheers,
mortb

"Me_Titus" <Me******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
After trying to solve thois bymyself i gave up. I was i visual basic 6
programmer, now i m getting to java and c#. The problem i have is simple, but
it seems to be a hell for me.

<EXPLANATION>

I' ve 2 forms, Form1 is one class and Form2 is another class. On form1
i've
a textbox (textBox1), and on form2 i've a button(button1). What i am
trying
to do is when i press the button on form2 i want to change the value of the
textBox1 placed on form1.

<CODE>

On Form1 a do the following:

Form2 v_Form = new Form2();
v_Form.Show.

with that a create a new instance of Form2 and i show it then.
On Form2 i did the following:

private void button1_click(.....)
{
Form1.ControlCollection["textBox1"].text="Marco";
}
</CODE>

</EXPLANATION>

I've tryied many otrher ways, to remenber that i set the control
(textBox1)
public in Form1.
Can you please help me on this.
Thank you
Me_Titus


Nov 16 '05 #5

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

Similar topics

6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
0
by: samlee | last post by:
Hi All, I'm learning how to write C# using reflection, but don't know how to code using reflection this.Controls.Add(this.label1); Could anyone help, Thank in advance. ...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
jinu1996
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...
0
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...

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.