Clicking on column header reorders row header (index)

Jun 29, 2012 at 9:56 PM

Hello,

I created a row header, a numeric value, like in Microsoft Excel, which shows the row number.  The problem is that clicking a column header to sort by that column changes the first column too.  The row numbers should be static.

What is the best course for a solution or coding the numeric row number (zeroth column).

Thanks,

Sarah

Jun 30, 2012 at 7:26 PM

Hello Sarah,

I spent some time going through the code.  It accounts for the number of header rows (usually just one), but does not take into account the number of columns containing a row header.  It is coded to start at column 0.  I solved the problem in an application I built some time ago, but it isn't pretty.  Basically, I created a new ColumnHeader object with the AutomaticSortEnabled property set to false.  Then I created a function to sort the range of the grid excluding column zero.  This function is called when there is a Mousedown event in row 0 (assumes only one row of column headers).  Since I was manually sorting the grid, I also had to add code to clear out any previous icon and display the new sort direction icon.  Not pretty, but it works.

Excel does not provide an Automatic Sort feature.  You have to go through the Data/Sort menu selection and specify the range to be sorted (default range includes all columns/rows excluding row zero and column 0.  Adding the same functionality (i.e. ability to specify the range) can be implemented with SourceGrid without too much work but then you would need a user interface to allow the user to specify the range.  Is that what you want or do you want the user to be able to sort automatically by clicking the column header?

Joe

Jul 2, 2012 at 2:47 PM
Edited Jul 2, 2012 at 2:47 PM

Hi Joe,

I just wanted to keep it simple.  The user can click on a column header, much like the default behavior now, just column zero (0), does not sort, as that is the row header.  The current functionality is fine, just it sorts the row header.

What you propose, to recode the entire sort functionality, seems like a lot of work simply to not sort the row index. :-(

Sarah

Jul 3, 2012 at 5:20 PM

If you don't mind touching the SourceGrid source, I can point you to where it is coded to include column 0.  You could change that to a 1.

Joe

Jul 3, 2012 at 10:26 PM

Sure, I can give it a try. :-)

Thanks,

Sarah

Jul 12, 2012 at 2:36 PM

Hi Joe,

I never heard back from you.  Can you point me to what I need to change in the source code?

Sarah