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

Texbox.Text from form A to Form B

I am learning c# and I have a problem. I would like to enter a username in
form A textbox and have it apper in form B testbox.

I have something like this

frmlaptopChk laptop = new frmlaptopChk();
txtusername.Text = laptop.txtUsername.Text ();

and when i run it, I get inaccessible due to its protection level

*Not this is from form B testbox
May 2 '07 #1
2 1295
freddy,

In order to do it the way that you want to, you have to set the
txtUsername field in the frmlaptopChk class to public or internal (assuming
these forms are hosted in the same assembly), so that you can access the
field.

However, I would have the frmlaptopChk class fire an event when the
textbox changes, and have the other form respond to that event. It's a much
better design, and doesn't tightly couple everything together.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"freddy" <fr****@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
>I am learning c# and I have a problem. I would like to enter a username in
form A textbox and have it apper in form B testbox.

I have something like this

frmlaptopChk laptop = new frmlaptopChk();
txtusername.Text = laptop.txtUsername.Text ();

and when i run it, I get inaccessible due to its protection level

*Not this is from form B testbox

May 2 '07 #2
Hi,
"freddy" <fr****@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
>I am learning c# and I have a problem. I would like to enter a username in
form A textbox and have it apper in form B testbox.

I have something like this

frmlaptopChk laptop = new frmlaptopChk();
txtusername.Text = laptop.txtUsername.Text ();

and when i run it, I get inaccessible due to its protection level

*Not this is from form B testbox

You have to make the value of Text available to the calling method.

There are more than one way of doing it.

One question, is formA a dialog? (you show it using ShowDialog() )

May 2 '07 #3

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

Similar topics

1
by: Phill Long | last post by:
Right, ok, well I have designed a form that will display a price (22.34) in a text box, and another price in the other text box... I also have a blank text box... Now I want to add both the prices...
1
by: Finn Ellermann | last post by:
How can I append text or data to a TextBox not using TextBox.Text += can any one help me Finn
3
by: Denise | last post by:
I am working with some pre-written code that dynamically builds a page with user controls based on data. I need to attach my Javascript to one of the controls on the form - I do not have access to...
4
by: Jan Nielsen | last post by:
Hi I have a dataform that shows a date from a MSDE 2000 in a textbox. It uses the format: dd-mm-yyyy hh:mm:ss It would it to use the format dd-mm-yyyy But I can't find a Format property for the...
1
by: Boni | last post by:
Dear Sirs, how is it possible to know if all text in a textbox is visible or the text was too long and a part is invisible? So I need to know max number of characters in visible space.
9
by: Marcel Saucier | last post by:
Hello, I want to create several texboxes on a form and I would like to refer to them (properties, etc) in a form of an array. Is that possible ? Example: Instead of...
1
by: pgreenhill | last post by:
Hi All, I'm creating a Form ("Menu") that has 2 listboxs in it. My problem is that I can't copy the values of each listbox, into another Form's textboxs. The idea is that users can...
4
by: Ken Fine | last post by:
I'm making an administrative interface that lists records in a GridView. For *each* row in the gridview, I would there to be two interface elements in addition to some information associated with...
6
by: Rakodu | last post by:
I have a situation i have a problem to solve my surveying data. Now i want it to respond to data which i input e.g if i put text not a value should make me aware and where i did that mistake.Below is...
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: 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
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
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
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
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,...

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.