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

C# initializing new modal dialog box

This is a newbie question.

I want to open a new dialog box. I have a couple of text boxes in it that I want to initialize. However, I can't seem to access them from the class from where I am opening the dialog. For instance, I want to init the EditLatitude text box, but I get this compiler error:
System.Windows.Forms.Form does not contain a definition for EditLatitude.
Expand|Select|Wrap|Line Numbers
  1.       private void EditLocationButton_Click(object sender, EventArgs e)
  2.         {
  3.             Form newLocationForm = new NewLocation();
  4.             newLocationForm.EditLatitude = m_nString;
  5.             newLocationForm.ShowDialog();
  6.         }
  7.  
I tried making EditLatitude public, but that didn't help. How can I tie a member variable in to the text box such that it is accessible from my whole app?
May 22 '07 #1
7 9451
Plater
7,872 Expert 4TB
You remembered to add a .Text after your object right?
if you set your textbox to "public" you should have access to it, check to make sure it did not revert back to private
May 22 '07 #2
TRScheel
638 Expert 512MB
This is a newbie question.

I want to open a new dialog box. I have a couple of text boxes in it that I want to initialize. However, I can't seem to access them from the class from where I am opening the dialog. For instance, I want to init the EditLatitude text box, but I get this compiler error:
System.Windows.Forms.Form does not contain a definition for EditLatitude.

private void EditLocationButton_Click(object sender, EventArgs e)
{
Form newLocationForm = new NewLocation();
newLocationForm.EditLatitude = m_nString;
newLocationForm.ShowDialog();
}

I tried making EditLatitude public, but that didn't help. How can I tie a member variable in to the text box such that it is accessible from my whole app?

This seems like what you need:

Expand|Select|Wrap|Line Numbers
  1. partial class MyDialogForm
  2. {
  3. // The other members of the class
  4.  
  5. public string TheText
  6. {
  7. get { return MyTextBox.Text; }
  8. set { MyTextBox.Text = value; }
  9. }
  10. }
May 22 '07 #3
Yes, I did that too. It kind of appears from the error message that it thinks my text box is a member of System.Windows.Forms.Form, rather than of my dialog box:

'System.Windows.Forms.Form' does not contain a definition for 'EditLatitude'
May 22 '07 #4
This seems like what you need:

Expand|Select|Wrap|Line Numbers
  1. partial class MyDialogForm
  2. {
  3. // The other members of the class
  4.  
  5. public string TheText
  6. {
  7. get { return MyTextBox.Text; }
  8. set { MyTextBox.Text = value; }
  9. }
  10. }
Thanks. That does look like what I need. I fear the class that Visual Studio generated for me for the modal dialog form is screwed up, though. If I try to access the get_setLatitude property from outside the class, I get error CS0117: 'System.Windows.Forms.Form' does not contain a definition for 'get_setLatitude'.
Here is my class:
Expand|Select|Wrap|Line Numbers
  1. namespace CombineSimCSharp
  2. {
  3.     public partial class NewLocation : Form
  4.     {
  5.         public string get_setLatitude
  6.         {
  7.             get
  8.             {
  9.                 return EditLatitude.Text;
  10.             }
  11.             set
  12.             {
  13.                 EditLatitude.Text = value;
  14.             }
  15.         }
  16.         public NewLocation()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.     }
  21. }
  22.  
Sorry for the newbie questions, and I really do appreciate your help.
May 22 '07 #5
TRScheel
638 Expert 512MB
Thanks. That does look like what I need. I fear the class that Visual Studio generated for me for the modal dialog form is screwed up, though. If I try to access the get_setLatitude property from outside the class, I get error CS0117: 'System.Windows.Forms.Form' does not contain a definition for 'get_setLatitude'.
Here is my class:
Expand|Select|Wrap|Line Numbers
  1. namespace CombineSimCSharp
  2. {
  3.     public partial class NewLocation : Form
  4.     {
  5.         public string get_setLatitude
  6.         {
  7.             get
  8.             {
  9.                 return EditLatitude.Text;
  10.             }
  11.             set
  12.             {
  13.                 EditLatitude.Text = value;
  14.             }
  15.         }
  16.         public NewLocation()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.     }
  21. }
  22.  
Sorry for the newbie questions, and I really do appreciate your help.
Um this sounds dumb... but restart your computer.

It looks like a VS bug I have came across before where it wont recognize members of classes and the autofill needs to be smacked.

Because if EditLatitude AND that property are both public, then it should see it.
May 22 '07 #6
epoch
3
did you try to change this line
Form newLocationForm = new NewLocation()

to this:
NewLocation newLocationForm = new NewLocation()

???
May 25 '07 #7
Plater
7,872 Expert 4TB
did you try to change this line
Form newLocationForm = new NewLocation()

to this:
NewLocation newLocationForm = new NewLocation()

???
That is a HUGE catch, I missed it myself. I would say that is TOTALLY the issue. Your custom form is getting cast as a basic Form at creation.
May 25 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Patrick Lim | last post by:
Here is the problem: I have written a non-modal frame class in Java for displaying help text when a user is using an application. It works as desired in that if the user selects "help" again,...
2
by: martin de vroom | last post by:
Hi, I have a web page that opens a modal dialog (client side) in the following manner onclick="window.showModalDialog('/dialog.asp',null,'dialogHeight: 200px; dialogWidth: 400px; dialogTop:...
2
by: Gilles T. | last post by:
Hi, How I can refresh a modal dialog in asp.net? I open a modal dialog in first with a dropdownlist. To add a element in my dropdownlist (table), I open a second modal dialog to ask element and...
2
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also...
3
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then...
10
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
2
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
2
by: diogenes | last post by:
I have created many shortcut/popup (aka context, or right-click) menus for my application - instead of toolbars or standard drop-down menus. Within my custom menu, I am using...
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: 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: 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...
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.