Click here to Skip to main content
15,921,694 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enable/Disable the keyboard and mouse Pin
Heath Stewart21-Apr-04 9:47
protectorHeath Stewart21-Apr-04 9:47 
GeneralRe: Listview Problem Pin
Nick Parker21-Apr-04 4:57
protectorNick Parker21-Apr-04 4:57 
GeneralRe: Listview Problem Pin
Heath Stewart21-Apr-04 6:42
protectorHeath Stewart21-Apr-04 6:42 
GeneralRe: Listview Problem Pin
Nick Parker21-Apr-04 17:15
protectorNick Parker21-Apr-04 17:15 
GeneralRe: Listview Problem Pin
Heath Stewart22-Apr-04 2:22
protectorHeath Stewart22-Apr-04 2:22 
GeneralRe: Listview Problem Pin
Nick Parker22-Apr-04 4:00
protectorNick Parker22-Apr-04 4:00 
GeneralRe: Listview Problem Pin
Reinier van de Wetering21-Apr-04 22:24
Reinier van de Wetering21-Apr-04 22:24 
GeneralRe: Listview Problem Pin
Heath Stewart22-Apr-04 2:35
protectorHeath Stewart22-Apr-04 2:35 
Why I personally perfer having the second form just return the data as a property or something, passing a reference to the first form isn't hard at all. Here's an example:
public class FirstForm : Form
{
  // ...
  private void btnSecondForm_Click(object sender, EventArgs e)
  {
    // For example, pass a referenec to "this" form into the constructor for
    // the second form.
    using (SecondForm form = new SecondForm(this))
    {
      form.ShowDialog(this);
    }
  }
  // Gets the ListView declared and initialized in this class.
  internal ListView TheListView
  {
    get { return theListView; }
  }
}
internal class SecondForm : Form
{
  // ...
  private FirstForm parent;
  public SecondForm(FirstForm parent)
  {
    this.parent = parent;
  }
  private void btnOK_Click(object sender, EventArgs e)
  {
    ListView view = parent.TheListView;
    if (view != null)
    {
      // Fill "view" with data.
      this.DialogResult = DialogResult.OK; // Closes form, too.
    }
  }
}
As you can see, though, not SecondForm is tightly coupled with FirstForm, which is why simply having the SecondForm define a property which returns the input data would be better, because then you could use it anywhere when you need to query for such data.

 

Microsoft MVP, Visual C#
My Articles
GeneralAdd Permission to a Registrykey with C# Pin
Sebastian Wittig21-Apr-04 4:21
Sebastian Wittig21-Apr-04 4:21 
GeneralRe: Add Permission to a Registrykey with C# Pin
Heath Stewart21-Apr-04 7:14
protectorHeath Stewart21-Apr-04 7:14 
GeneralRe: Add Permission to a Registrykey with C# Pin
Sebastian Wittig21-Apr-04 21:08
Sebastian Wittig21-Apr-04 21:08 
GeneralDataGridBoolColumn Pin
bertcox21-Apr-04 4:20
bertcox21-Apr-04 4:20 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart21-Apr-04 7:16
protectorHeath Stewart21-Apr-04 7:16 
GeneralRe: DataGridBoolColumn Pin
bertcox21-Apr-04 21:53
bertcox21-Apr-04 21:53 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 2:29
protectorHeath Stewart22-Apr-04 2:29 
GeneralRe: DataGridBoolColumn Pin
bertcox22-Apr-04 2:58
bertcox22-Apr-04 2:58 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 3:59
protectorHeath Stewart22-Apr-04 3:59 
GeneralRe: DataGridBoolColumn Pin
bertcox22-Apr-04 4:09
bertcox22-Apr-04 4:09 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 4:18
protectorHeath Stewart22-Apr-04 4:18 
GeneralRe: DataGridBoolColumn Pin
bertcox22-Apr-04 4:30
bertcox22-Apr-04 4:30 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 4:33
protectorHeath Stewart22-Apr-04 4:33 
GeneralRe: DataGridBoolColumn Pin
bertcox22-Apr-04 4:45
bertcox22-Apr-04 4:45 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 4:55
protectorHeath Stewart22-Apr-04 4:55 
GeneralRe: DataGridBoolColumn Pin
bertcox22-Apr-04 5:04
bertcox22-Apr-04 5:04 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 5:05
protectorHeath Stewart22-Apr-04 5:05 

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.