Freeze 1st, 3rd, 6th column in Telerik RadGrid control in silverlight - silverlight

I have a RadGrid property to Freeze columns by setting the count.
For ex if i set "FrozenColumnCount="1"" the first column of grid will be freezed. By increasing this count can set that many number of columns freeze.
But i want to do for Different columns like random coulmns.
Please help me on this. Thanks.

You can use the index of the column to do it like this :
myGridView.Columns[1].IsFrozen = true;
myGridView.Columns[3].IsFrozen = true;
myGridView.Columns[6].IsFrozen = true;

Just imagine how the UI behaviour would be when scrolling :)
But you can always first reorder the columns to make the desired columns be the first n ones and then set the FronzenColumnCount to n

Related

How To Highlight a Column in a WinForm StackedColumn Chart

I'd like to highlight a single column in a WinForm StackedColumn Chart. As examples, I'm seeing how to put borders around the individual DataPoints in each Series displayed in the column and put an ArrowAnnotation pointing at one of the DataPoints, but I don’t see a way to highlight the column as a whole. For example, it would be great to have the column expand to say twice the width of the other columns and/or have a different backcolor (including the empty areas above and below the DataPoints). Is it possible to do what I want and, if so, how? C# examples are preferable but not necessary.
Thanks. Steve
You could dim every other column, using BackHatchStyle = ChartHatchStyle.Percent50 and BackSecondaryColor = Color.Black. This will make your chosen column appear brighter/highlighted.
Here's an example:
int highlightColumnIndex = 0; // Set the highlighted column here!
foreach (Series cs in chart1.Series) {
foreach (DataPoint dp in cs.Points) {
dp.BackSecondaryColor = Color.Black;
dp.BackHatchStyle = ChartHatchStyle.Percent50;
}
cs.Points[highlightColumnIndex].BackHatchStyle = ChartHatchStyle.None;
}
Change chart1 to your chart's name, and change highlightColumnIndex to match the index of the column you want to highlight.
Hope this helps :)

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??

Grid index out of range on scrolling

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.

Silverlight How to Move Control Between Grid rows?

How I can move control from one row of Grid to another without remove the control from the first row and then add it to the second row???
Thanks
Assuming you want to do this at run-time, in the code-behind, you can try:
// Assuming your control is not in row 1
myControl.SetValue(Grid.RowProperty, 1)
Why? To get this done easily, you have to change the row that it is in.
Another way is to use math and do calculation of the height of grid, row and control and position it by margin. - very messy code.

Programatically bringing a Datagrid column into view (horizontal scroll)

I would like to bring a column into view programatically. I have a lot of columns and when they are off screen i would like to select a cell and bring that cell into view, i can select a cell that is off screen and when i horizontal scroll to bring the cell visible the cell is selected.
i know you can do this with the rows, i.e ScrollIntoView but how about columns?
anyone had any luck doing this? and if so how :) (of course)
Answer : use the datagrid method.
public void ScrollIntoView(object item, DataGridColumn column);
which takes a column. simple.
aran, suppose you want to go to 30 th column, try setting the horizontal offset of the scroll viewer.
like,
columnCount = 30;
offset = columCount * Columnwidth
scrollViewer.ScrollToHorizontalOffset(offest);
best,
Quafin

Resources