473,382 Members | 1,752 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.

Noob question...

I have a windows form that loads and displays a dialog box...

The user inputs a few strings into this dialog box.

I want to be able to store these strings and make them accessible to
the scope of the entire application.

So my question is how do I make reference to a string that was
inititilized somewhere else?

Jul 17 '06 #1
2 1397
rhaazy, the easy way is to...

Create some public properties that return the textbox.text of the
dialog's textboxes, and then retrieve the values in your main form just
after the line that shows your dialogue - which is where your main form
will start executing again after the dialog is closed.

ie

class MainForm
{
private string m_sStringFromDialog;

private void ShowMyDialogue()
{
//create a new dialog object called 'frm'
....
//show the dialogue
frm.ShowDialog();
m_sStringFromDialog = frm.MyString
}
....
}

class OtherDialog
{
public string _Text1 { get { return TextBox1.Text; } }
....
}

rhaazy wrote:
I have a windows form that loads and displays a dialog box...

The user inputs a few strings into this dialog box.

I want to be able to store these strings and make them accessible to
the scope of the entire application.

So my question is how do I make reference to a string that was
inititilized somewhere else?
Jul 17 '06 #2

pigeonrandle wrote:
rhaazy, the easy way is to...

Create some public properties that return the textbox.text of the
dialog's textboxes, and then retrieve the values in your main form just
after the line that shows your dialogue - which is where your main form
will start executing again after the dialog is closed.

ie

class MainForm
{
private string m_sStringFromDialog;

private void ShowMyDialogue()
{
//create a new dialog object called 'frm'
...
//show the dialogue
frm.ShowDialog();
m_sStringFromDialog = frm.MyString
}
...
}

class OtherDialog
{
public string _Text1 { get { return TextBox1.Text; } }
...
}
I think that that last bit should have been:

class OtherDialog
{
public string MyString { get { return TextBox1.Text; } }
....
}

Jul 17 '06 #3

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

Similar topics

10
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character...
3
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
8
by: Ivan Shevanski | last post by:
Alright heres another noob question for everyone. Alright, say I have a menu like this. print "1. . .Start" print "2. . .End" choice1 = raw_input("> ") and then I had this to determine what...
2
by: Chris Dunaway | last post by:
I was looking over some asp.net code and saw this asp:Image control: <asp:Image ImageUrl="~/images/logo.gif" runat="server" ID="Image1"/> What does the tilde (~) mean in the ImageUrl...
2
by: Nonee | last post by:
Hello- I am writing a program that loads a tv guide listing into a control. I looked at the datagridview control but it doesn't seem to have the ability to overlap columns. Basically, I would...
2
by: Dan McCollick | last post by:
Hi All, Noob question that I can not seem to figure out: I am trying to implement a screenscraper to pull data from two seperate websites, here is some test code so far: public static void...
2
by: tavspamnofwd | last post by:
I'm a total noob, and I'm trying to understand this code: var newsi = { name:"newsi", dom:false }; newsi.Client=function(){ //stuff }
6
by: Lang Murphy | last post by:
I'm baaaaack... some of you answered a question I had last week. Only problem is: I'm a dope who doesn't understand most of what y'all posted. Raw noob when it comes to .Net and C#. So I'm going...
0
by: irtehnoob | last post by:
Hi there, I'm pretty new to c# (started up a few days ago) and I'm making a simple program, so far everything is going good except I can't figure somethine out.. hence why I'm here. Anyways, in my...
1
by: SCRIPT KEEPER | last post by:
Hello, I am a complete noob and just starting off with csharp so I apologize for my basic question. I am wanting to start powershell from inside a batch script and then to pass the powershell args...
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: 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
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...
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...

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.