new rows are added to top of DataGridView

  • Thread starter Thread starter craig.wenger
  • Start date Start date
C

craig.wenger

I am using a DataGridView to display information stored in classes. I
am linking to the information with the Tag property of the
DataGridView rows. Unfortunately, whenever I set the Tag property,
update all its associated cells, and then add a new row, it adds the
blank row to the top of the grid. It seems like it would be more
logical to me to add the new row to the bottom of the grid. Before I
started using the Tag property of the rows, and just kept an
independent list of items to store the information, I didn't have this
problem, even though I am not sure what the difference is.
 
Is your DataGridView or its datasource sorted? Is the new row being
placed in it proper psoition in the sort order?

======================
Clay Burch
Syncfusion, Inc.
 
Is your DataGridView or its datasource sorted? Is the new row being
placed in it proper psoition in the sort order?

======================
Clay Burch
Syncfusion, Inc.

No, all of the columns are set to NotSortable. There is no true
datasource because I just use the Tag property of each row, there is
no actual data binding.
 
I am using a DataGridView to display information stored in classes. I
am linking to the information with the Tag property of the
DataGridView rows. Unfortunately, whenever I set the Tag property,
update all its associated cells, and then add a new row, it adds the
blank row to the top of the grid. It seems like it would be more
logical to me to add the new row to the bottom of the grid. Before I
started using the Tag property of the rows, and just kept an
independent list of items to store the information, I didn't have this
problem, even though I am not sure what the difference is.

It seems the Tag property only stays with the bottom row. Even after
adding two rows and setting the Tag property only one row will show
this value as something other than null. Maybe the Tag property is not
the best approach for this. I guess a more general question would be,
is there any way to link classes to rows in a DataGridView without
databinding and without maintaining a separate list. A separate list
would get tricky in that event that the DataGridView is sorted.
 
It seems the Tag property only stays with the bottom row. Even after
adding two rows and setting the Tag property only one row will show
this value as something other than null. Maybe the Tag property is not
the best approach for this. I guess a more general question would be,
is there any way to link classes to rows in a DataGridView without
databinding and without maintaining a separate list. A separate list
would get tricky in that event that the DataGridView is sorted.

I figured it out. I was editing the 'new' row at the bottom of the
DataGridView and then adding a new row, instead of adding a new row
and then editing it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top