Click here to Skip to main content
15,905,232 members
Home / Discussions / C#
   

C#

 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 5:18
gamer112724-Jan-10 5:18 
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 5:32
Jimmanuel24-Jan-10 5:32 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 5:53
gamer112724-Jan-10 5:53 
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 5:58
Jimmanuel24-Jan-10 5:58 
GeneralRe: Transferring focus from a textbox to a button Pin
ragnaroknrol25-Jan-10 2:36
ragnaroknrol25-Jan-10 2:36 
QuestionMy Options Window Pin
Jassim Rahma24-Jan-10 1:50
Jassim Rahma24-Jan-10 1:50 
AnswerRe: My Options Window Pin
Som Shekhar24-Jan-10 2:22
Som Shekhar24-Jan-10 2:22 
QuestionPassing and displaying variables in forms Pin
Wogboiii23-Jan-10 23:36
Wogboiii23-Jan-10 23:36 
Hi All, just a note before you start reading, I wanted to apologize in advance for going into so much detail but I wanted to be thorough... if perhaps confusing in places





OK, so whats happening is that I'm having trouble getting data to display when they are passed to a form.

What's meant to happen is that the form NotesWindow (form2) (which is initialized by the main form) is meant to initialize a third form NewNoteWindow (form3) which takes text input from the user and then passes it back to NotesWindow (form2) which is meant to display it in a listbox.

I have managed to, using a constructor pass the data from NewNoteWindow (form3) to NotesWindow (form2) but it will only display if I hide NotesWindow (form2) after getting it to open NewNoteWindow (form3) and then using NotesWindow.Show() from NewNoteWindow (form3) to bring up the form again.

My theory as to why this is happening is that I initialize NewNoteWindow (form3) from NotesWindow (form2) using NewNoteWindow newNoteWindow = new NewNoteWindow and then to pass the data back I need to initialize NotesWindow (form2) in NewNoteWindow (form3) using NotesWindow notesWindow = new NotesWindow I suspect that this is creating a new instance of NoteWindow (form2) and sending the data to that as opposed to the already open NotesWindow (form2).

If I'm right about that, anyone know how to send the data back to NotesWindow (form2) properly, if I'm wrong then anyone know what I'm doing wrong?

I'll include what I believe to be the relevant pieces of code at the bottom, if u want any more of the code or if you need me to clarify anything just ask.

Another problem I have had is that when I go to input a second piece of data the listbox is cleared of its data, I don't know if this is because of the this.hide() and NotesWindow.Show methods or because I'm initializing another instance of NotesWindow (form2) (I believe it's this reason) or something completely different.


Thanks in advance for any insight you can offer about my problem.



Relevant Code In NotesWindow (Form2)

NewNoteWindow newNoteWindow = new NewNoteWindow();


public string NewNote1
{
    set
    {
        notesDisplayBox.Items.Add(value);
        label1.Text = value;
    }
}


private void addNewButton_Click(object sender, EventArgs e)
{
    newNoteWindow.ShowDialog();
    //this.Hide(); <----- this is where I hide form2 after showing form3
}


Relevant Code in NewNoteWindow (Form3)

public string NewNoteTextBox
{
    get
    {
        return newNoteTextBox.Text;
    }
}


private void okButton_Click(object sender, EventArgs e)
{
    NotesWindow notesWindow = new NotesWindow(); <--- I initialize this here because if I do it //at the top of the form it gives me an infinite loop error (this is why I believe my problem is that I //am initializing another instance of Notes Window (form2)
    notesWindow.NewNote1 = NewNoteTextBox;
    notesWindow.label1.Text = newNoteTextBox.Text;
    //notesWindow.Show(); <----- This is where I show form2 again if I don't do this and the //this.hide in form2 the data does not display in the listbox
    this.Close();
}




Sorry again for making you read through all that, but I did want to be thorough.

Peace
AnswerRe: Passing and displaying variables in forms Pin
Som Shekhar23-Jan-10 23:51
Som Shekhar23-Jan-10 23:51 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 0:01
Wogboiii24-Jan-10 0:01 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 0:05
Som Shekhar24-Jan-10 0:05 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 0:09
Wogboiii24-Jan-10 0:09 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 0:14
Som Shekhar24-Jan-10 0:14 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 17:21
Wogboiii24-Jan-10 17:21 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 17:47
Som Shekhar24-Jan-10 17:47 
AnswerRe: Passing and displaying variables in forms Pin
sanforjackass24-Jan-10 0:15
sanforjackass24-Jan-10 0:15 
AnswerRe: Passing and displaying variables in forms Pin
#realJSOP24-Jan-10 2:05
professional#realJSOP24-Jan-10 2:05 
Questionlabel size Pin
jojoba201023-Jan-10 23:17
jojoba201023-Jan-10 23:17 
AnswerRe: label size Pin
Luc Pattyn23-Jan-10 23:28
sitebuilderLuc Pattyn23-Jan-10 23:28 
QuestionRe: label size Pin
jojoba201023-Jan-10 23:30
jojoba201023-Jan-10 23:30 
AnswerRe: label size Pin
Luc Pattyn23-Jan-10 23:49
sitebuilderLuc Pattyn23-Jan-10 23:49 
AnswerRe: label size Pin
OriginalGriff23-Jan-10 23:32
mveOriginalGriff23-Jan-10 23:32 
AnswerRe: label size Pin
dan!sh 23-Jan-10 23:47
professional dan!sh 23-Jan-10 23:47 
QuestionRe: label size Pin
jojoba201023-Jan-10 23:52
jojoba201023-Jan-10 23:52 
AnswerRe: label size Pin
dan!sh 24-Jan-10 4:15
professional dan!sh 24-Jan-10 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.