Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello,

My problem:
I have a programm, in this you can see a datagrid (binding with a SQL database).
The grid is a DevExpress GridControl.
now when you double click on a row in this grid, it open a new Window. The new Window becomes the selectet/clicked row as parameter.
Now you can do much things, write datas in the Database... that all works fantastic. when i do a SQL-command, i need the ID from this person, this i have, from the parameter.

Now the Problem: When i open this form 2 times, it doesn´t work...
For example:
1. Start the Program
2. select a person from the Grid -> new window open
3. select an other person from the Grid -> again new window open
4. do something in person 1, and close it
5. do something in the other person. Here this changes are not saved!!!!!

The problem is, that the second doubleclick, overrides the ID from the thirst person wird the new ID...

How i can open 2 windows and know which ID ist which window?

I hope you know what i mean, and can help me or give me a tip what i must do...

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 8-Jun-15 12:14pm    
Why not changing selection mode to one row at a time or one cell at a time mode?
—SA

1 solution

A short-hand solution to this problem is to create a private field to store the ID, and while creating the new Window pass the parameter to the window before showing it.

C#
public class MyWindow : Window {
   // Field
   private int ID { get; set; }

   // Constructor
   public MyWindow() {
      InitializeComponent();
   }

   public MyWindow (int id) { 
      ID = id; // set the ID
      InitializeComponent();
   }
}


Now, each instance would hold different ID. You can then use this to differentiate between instance of the Window.
 
Share this answer
 
v2
Comments
Fabian Minis 9-Jun-15 3:38am    
Thank you, now it works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900