Click here to Skip to main content
15,888,286 members
Home / Discussions / C#
   

C#

 
AnswerRe: Exception: Syntax Error in INSERT TO. Pin
PIEBALDconsult11-Jul-12 3:37
mvePIEBALDconsult11-Jul-12 3:37 
QuestionPassing an object through different window classes in Windows Forms Pin
nstk11-Jul-12 0:55
nstk11-Jul-12 0:55 
AnswerRe: Passing an object through different window classes in Windows Forms Pin
Pete O'Hanlon11-Jul-12 1:02
mvePete O'Hanlon11-Jul-12 1:02 
GeneralRe: Passing an object through different window classes in Windows Forms Pin
nstk11-Jul-12 3:47
nstk11-Jul-12 3:47 
GeneralRe: Passing an object through different window classes in Windows Forms Pin
DaveyM6911-Jul-12 4:02
professionalDaveyM6911-Jul-12 4:02 
GeneralRe: Passing an object through different window classes in Windows Forms Pin
nstk12-Jul-12 1:36
nstk12-Jul-12 1:36 
GeneralRe: Passing an object through different window classes in Windows Forms Pin
nstk12-Jul-12 1:44
nstk12-Jul-12 1:44 
AnswerRe: Passing an object through different window classes in Windows Forms Pin
BobJanova11-Jul-12 2:41
BobJanova11-Jul-12 2:41 
There's two common approaches I use for modal dialogs. The first is to write a method in StudentsDataForm (yes I just renamed your class Smile | :) ) which takes the Student, shows the form and returns a modified version:

public Student EditStudent(Student input){
 this.firstNameTextBox.Text = input.FirstName;
 // ... etc to copy data into other controls
 // you could also use data binding
 if(DialogResult.OK == ShowDialog()){
  Student result = new Student();
  result.FirstName = firstNameTextBox.Text;
  // etc
  return result;
 } else return input;
}


There's also a variant of this where you update the input object in place, and return the DialogResult, which you can use if you always want the data object to be updated by the form when OK is used.

The second way is to have a property in the second form:
public Student Student {
 get {
  Student student = new Student();
  student.FirstName = firstName.Text;
  // etc
  return student;
 }
 set {
  firstName.Text = value.FirstName;
  // etc
 }
}


Then you push the data into the form, and use the data from it if the user pressed OK:
studentDataForm.Student = someStudent;
if(DialogResult.OK == studentDataForm.ShowDialog(this)){
 // Do something with studentDataForm.Student to store the changed data
}

GeneralRe: Passing an object through different window classes in Windows Forms Pin
nstk14-Jul-12 7:40
nstk14-Jul-12 7:40 
QuestionData to and from object? Pin
Ronnie_B11-Jul-12 0:55
Ronnie_B11-Jul-12 0:55 
QuestionShared memory Applicaion <->Service Pin
Sebastian_G11-Jul-12 0:07
Sebastian_G11-Jul-12 0:07 
QuestionCan I Apply Autocomplete to the master page in asp.net Pin
Nitin_Kadam10-Jul-12 22:50
Nitin_Kadam10-Jul-12 22:50 
AnswerRe: Can I Apply Autocomplete to the master page in asp.net Pin
DaveyM6911-Jul-12 0:03
professionalDaveyM6911-Jul-12 0:03 
QuestionUsing Dotnet Login code in HTML doc Pin
ASPnoob10-Jul-12 21:35
ASPnoob10-Jul-12 21:35 
AnswerRe: Using Dotnet Login code in HTML doc Pin
AmitGajjar10-Jul-12 22:08
professionalAmitGajjar10-Jul-12 22:08 
AnswerRe: Using Dotnet Login code in HTML doc Pin
BobJanova11-Jul-12 2:06
BobJanova11-Jul-12 2:06 
GeneralRe: Using Dotnet Login code in HTML doc Pin
ASPnoob11-Jul-12 3:08
ASPnoob11-Jul-12 3:08 
GeneralRe: Using Dotnet Login code in HTML doc Pin
BobJanova11-Jul-12 4:36
BobJanova11-Jul-12 4:36 
QuestionDelete Excel File Pin
Member 916988710-Jul-12 21:08
Member 916988710-Jul-12 21:08 
AnswerRe: Delete Excel File Pin
Richard MacCutchan10-Jul-12 21:16
mveRichard MacCutchan10-Jul-12 21:16 
AnswerRe: Delete Excel File Pin
zhxhdean11-Jul-12 20:28
zhxhdean11-Jul-12 20:28 
QuestionUnderstanding Basics About Forms Pin
AmbiguousName10-Jul-12 19:59
AmbiguousName10-Jul-12 19:59 
AnswerRe: Understanding Basics About Forms Pin
Richard MacCutchan10-Jul-12 21:15
mveRichard MacCutchan10-Jul-12 21:15 
AnswerRe: Understanding Basics About Forms Pin
lukeer10-Jul-12 21:23
lukeer10-Jul-12 21:23 
GeneralRe: Understanding Basics About Forms Pin
DaveyM6910-Jul-12 23:55
professionalDaveyM6910-Jul-12 23:55 

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.