display row number in datagrid?
-
What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Thanks for any help. -Sam
sammyh wrote: What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Insert a column into the underlying DataTable and number it? Well, that's one idea. Probably not the best. Marc MyXaml Advanced Unit Testing YAPO
-
sammyh wrote: What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Insert a column into the underlying DataTable and number it? Well, that's one idea. Probably not the best. Marc MyXaml Advanced Unit Testing YAPO
The problem with that is once you sort the data your "row numbers" are off. Note that you must use the
DataView
's view of the row, not theDataTable
. Through theCurrencyManager
this is typically pretty easy, but I still don't know of a decent way off the top of my head to display and manage that data in aDataGrid
. Thank goodness for the DataGridView[^] in .NET 2.0. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog] -
The problem with that is once you sort the data your "row numbers" are off. Note that you must use the
DataView
's view of the row, not theDataTable
. Through theCurrencyManager
this is typically pretty easy, but I still don't know of a decent way off the top of my head to display and manage that data in aDataGrid
. Thank goodness for the DataGridView[^] in .NET 2.0. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog] -
DataGrid is such an awkward control, a major pain if you ask me. I'm looking forward to using .NET 2.0. Any tips to get me in the right direction. Or should I opt for a 3rd party control? Thanks, Sam
If you're not tied to .NET 1.x, I suggest you download Visual Studio 2005 Beta 2[^] and start working with .NET 2.0. You can also get a Go-Live License[^], which is an addendum to the EULA that allows you to distribute applications based on beta 2 into the production environment. If you need a solution now, I would first suggest some serious research (googling, newsgroups at http://msdn.microsoft.com/newsgroups[^], etc) and then consider a third-party solution. If and when you do move to .NET 2.0 your third-party control would be obsolete, though - honestly - most third-party controls are pretty inexpensive and typically royalty-free. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]