Grid index out of range on scrolling - tstringgrid

i have this problem:
I needed to hide a row in a string grid so i simply did something like:
StringGrid.RowHeights[StringGrid.Row] := 0;
So this basicly sets the row height to 0 and it looks hidden. But after i do this and if i try to scroll i got a "Grid index out of range". If i click on another cell the error doesn't show up after i scroll. So it only shows when i hide it and then scroll directly after hiding a row.
Why does this happen and how can i fix it please?

You are not quite supposed to do that. Instead of making the heights 0 you can simply 'skip' putting the data in the rows you want to hide.
For example, your table is like this:
a b c
d e f
and you want to hide the second row, then you say: RowCount:= RowCount-1 and simply don't display the data in that row.
For this you need a procedure (let's call it RefreshData) which will show the data in the grid, will decide which data rows to show or not and will calculate how many rows the grid should have.

I had a problem where I'd get the grid index out of range error when attempting to modify colcount or rowcount on a stringgrid. I debugged the grid.pas and figured out the error was because I was accidentally setting the ColWidth property of the negative first column to -1 like ColWidth[-1] = -1. That had the effect of modifying some memory of an array that stores the list of widths of each column and the control would act as if the columns and rows did not exist when attempting to add more. Only putting this here because I searched all over the internet to find the answer and there was nothing so maybe someone else will make the same mistake.

Related

Fixed row in DevExtremeREACTIVE

Im using DevExtremeREACTIVE grid. Need to fix one row. As I understood from documentations its very easy for columns, but couldn't find anything for rows.
In the picture marked row should be fixed while user scrolling vertically.

WPF DataGrid - Adding Rectangles to DataGrid cells in codebehind

I have a DataGrid that is populated in Codebehind using its DataContext. So the columns are auto generated and the actual number of columns generated do change.
Ultimately I need to be able to display a barchart in the Cells (col) depending on the value of a cell in another field (Col + 1).
My initial thoughts are to add a rectangle and change its width to the percentage of the cell width based on the value in col + 1 - but I am failing to find where to start doing this entirely in code behind.
Has anyone done this or have any advice that might help me get to what I am looking for please?
I can give more information if required.
EDIT:
As Requested, I thought I would try and visualize what I am after better. So, my Datagrid is populated with data similar to the following:
where there are 3 sets of 2 columns (a Perc & Result column for 1, 2 & 3... This number could be up to anything!). Now, the value in the Perc column is referenced to conditionally control the style of rectangles that sit in the respective Result columns (in this example I am using colours to represent the percent. In reality I am looking to use the perc value to set the width of the coloured rectangle in the Datagrid cell to give a barchart appearance).
Finally, I will hide all the Perc columns so the results will look like:
Does that mke any more sense... I hope I havent confused things further??

Extjs Grid, how do make last row unsortable?

Taking a look at the example at: http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/locking-grid.html
The last row at the bottom is "wal-mart". How would I make that bottom row unsortable?
The way it is now, if I sort any column, Wal-mart may potentially move with the sort, and no longer be at the bottom. I want it to stay at the bottom, because I'm going to turn the bottom row into a "totals" row that will add up the values of all the rows above it, so it needs to stay at the bottom.
If the purpose of the row is to provide summary then you can use grid Summary feature and then you don't need to solve the problem of sorting.

Having issues with Infragistics column resizing

I have a grid and I would like to automatically resize the columns. I'm running into inconsistencies when using different parameter values for PerformAutoResize(). When passing in the values below, where the true means include column headers:
PerformAutoResize(PerformAutoSizeType.VisibleRows, true);
some columns will be resized based solely on the header, while others will resize properly based on both the header and the row values.
However, if I hardcode in a value:
PerformAutoResize(20);
It works fine for every column.
Why is this?
UPDATE
Through some trial and error I've come to the conclusion that I think the issue is that I bring in the data and then have it auto-sort by a certain row. When using a hard coded value, it appears to auto-size the columns after that initial auto-sort, whereas when I use PerformAutoSizeType.VisibleRows it appears to auto-size the columns before the initial auto-sort.
Does PerformAutoResize(PerformAutoSizeType.AllRowsInBand, true); give you the results that you are looking for?
If so then is it possible that when you make the call that the row that you want to size the grid by isn't visible?

Any 3rd party Table like controls for WPF?

I know about Grid. What I don't like about Grid is that I have to specifically index every single row and col. So afterwards, if I want to just move one row or col, I have to go update a ton of xaml.
I tried stackpanel and styles but then even this is a lot of redundant xaml and rearanging the screen still involves then removing/updating styles.
I really like how in an html table, I just start laying out my rows and cols on the fly. If I want to move a row, that's easy, I can just copy paste the xaml to the right spot, nothing else needs to get touched. A col, is a bit harder, but still can be done easily with cut/paste, just needs to be done to every row.
With grid, one may need to touch every single thing in it depending on what's moved.
And what would be really cool, is if one could declare the column width and row heights up above just like a grid. But then as need, provide override values in the actual row,col declaration down below that actually contains the gui elements.
Does anything like this exist?
I've seen implementation of a Grid that infers ColumnDefinitions from usage of attached properties. Its definately doable. You could create an attached property that signifies that this element is the last element of a row.
(See WrapBreakPanel in Pro Silverlight 4 in C# By Matthew MacDonald)
And what would be really cool, is if one could declare the column
width and row heights up above just like a grid. But then as need,
provide override values in the actual row,col declaration down below
that actually contains the gui elements.
Sounds like this could get confusing. What if multiple cells in a row override the height? You can pull this off already with Auto sizing a row and having elements take up more space as needed.

Resources