How to fill the row header with a auto-increasing number?

Sep 17, 2008 at 9:35 AM
In the DataGridCTPSample, the row header is bind with the 'Id'.
If I want to fill the row header with a auto-increasing number just like that in excel, how can I get it?
thanks a lot!
Coordinator
Sep 17, 2008 at 12:21 PM
Are you talking about the DataGridCTPSample from http://blogs.msdn.com/vinsibal/archive/2008/08/11/net-3-5-sp1-and-wpf-datagrid-ctp-is-out-now.aspx?  If so, that should be an example of how to do an auto-incrementing Id.
Sep 18, 2008 at 2:37 AM
yes, I am talking about that DataGridCTPSample.
In that example, the row header is bind with the 'Id', when the user resort the rows by other columns, the numbers in row header will be disordered.
I don't want that. I want the row header number always be in order just like that in excel.
Can I get it? Thx!
Coordinator
Sep 19, 2008 at 4:00 AM
So it looks that you don't want the numbers in the row header to really be associated with each data item but more associated with the DataGrid itself.  If you can wait till the full release there will be a LoadingRow event that you can attach to.  In the event you can set the header each time to the number you want based on the item in the event args.  If you can't wait, another option is to override the DataGrid.PrepareContainerForItemOverride and set the header in the same way described above after calling base.PrepareContainerForItemOverride.