Source Code Change Request: Bug Fix / Feature Add

Aug 7, 2012 at 9:24 PM

I am not familiar with the procedure to modify the source code and implement a bug fix / feature add to the master source code repository for this product, so that future releases will incorporate the fix / change.

(Bug fix or feature add depends upon one's point of view, so I include both terms.)

I started another thread for the feature/bug in question, but since then I fixed it.  In this thread, I would like the change incorporated.

Problem: Sorting a table with header rows causes the the row header to sort as well.  That is a bug.  Microsoft Excel and other spreadsheets/tables do not have this behavior.

I modified Grid.cs to incorporate the fix.  I also added a new property, called SortRowHeader, which I set by default to true, so that previous behavior is left unchanged and only those that want this new behavior will get it by explicity setting this grid property to true.

Note, that none of the samples have row headers.  I added one on my end.  I am not sure if I can add a new sample too.  If I can add a new sample to the master code repository, then let me know the procedure.  I needed something to test / play with while I implemented the change.

Changes made to 4.40 source base:

Addition: Add the following 7 lines after line 524 (last line is a blank line)

		private Boolean m_SortRowHeader = true;
		public Boolean SortRowHeader
		{
			get { return m_SortRowHeader; }
			set { m_SortRowHeader = value; }
		}

With new numbering:

Change: line 670

Current:

			if (e.Range.ColumnsCount == ColumnsCount)

New:

			int iRangeColStart = e.Range.Start.Column;
			Boolean bRowHeader = false;
			if (false == SortRowHeader && e.Range.ColumnsCount == ColumnsCount && 0 < this.RowsCount && 0 < this.ColumnsCount && this[1, 0] is SourceGrid.Cells.RowHeader)
			{
				iRangeColStart++;
				bRowHeader = true;
			}
			if (false == bRowHeader && e.Range.ColumnsCount == ColumnsCount)

Old Line 713:

					l_RangeSort[zeroRowIndex] = new Cells.ICell[e.Range.End.Column-e.Range.Start.Column+1];
					for (int c = e.Range.Start.Column; c <= e.Range.End.Column; c++)

New Line 727:

     l_RangeSort[zeroRowIndex] = new Cells.ICell[e.Range.End.Column-iRangeColStart+1];
     for (int c = iRangeColStart; c <= e.Range.End.Column; c++)

Old Line 731:

						for (int c = e.Range.Start.Column; c <= e.Range.End.Column; c++)

New Line 745:

						for (int c = iRangeColStart; c <= e.Range.End.Column; c++)

Old Line 750:

						for (int c = e.Range.Start.Column; c <= e.Range.End.Column; c++)

New Line 764:

						for (int c = iRangeColStart; c <= e.Range.End.Column; c++)

Addition: Between old 763/764 and just after new 777:

				this.Invalidate();
				this.Refresh();

Thanks,

Sarah

 

 

 

 

 

Aug 22, 2012 at 5:46 PM

Update:  I added an item in the patch section for this issue.

Sarah

Aug 22, 2012 at 5:46 PM

Update:  I added an item in the patch section for this issue.

Sarah