|
-
Oct 21st, 2022, 03:48 AM
#2
Re: DataGridView item editing is not following
 Originally Posted by pourkascheff
1) Why when I show Form2, It opens and shows DGV with rows (either with correct or incorrect values) for first time, but when I open it for 2nd time and so on it is completely blank and empty?
By using the type name, you are referring to the default instance of Form2. You can read about default instances here. When you call Show to display a form, closing that form will dispose it. That means that, the next time you use the default instance, a new Form2 instance is created. That new instance doesn't know anything about the rows you added to the previous instance.
A potential solution is to add your rows to a list of some sort, which might be a DataTable or a generic List of a custom type or whatever. You can then pass that list to each Form2 instance and it can bind it to its own grid. Every instance will then be displaying the same data and your main form always holds that data. This could also make your second question moot, because you could add the row number when you add the row to the list.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|