Hi Everyone
I have Ultragrid and i have column called text where there is some text and other columns like font-family,style,size,weight,color,backcolor,border and bordercolor. If i change some values in this it should get reflected in the text column according to the chosen values from all these.
I tried to do it in but i couldn get it i dont know where i have gone wrong.
Is there any way to do it.
Colud someone help me please
Thanks in advance
Ferdin
Ferdin,
You could use the InitializeRow event to check when the value in your formatting columns have been updated and then change the value of the cell in the Text column of that row accordingly. The best way to do this would be to use a Style on the Text column of FormattedText or FormattedTextEditor. You would likely need to build the string of formatting yourself, though.
The structure that I'm referring to for the InitializeRow event is:
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e){ string fontFamily = e.Row.Cells["FontFamily"].Value.ToString(); string fontSize= e.Row.Cells["FontSize"].Value.ToString(); // Build the formatted string here e.Row.Cells["Text"].Value = myFormattedText;}
For an example of what string to build, you could add an UltraFormattedTextEditor to your form and click on the UITypeEditor (the button with '...') on the Value property, then use the dialog that shows up to create a formatted string. You can see the raw value that is generated there to see how it is structured. You can also find a list of supported xml tags here.
-Matt
Hi Matt,
Sorry for digging this up, but I encountered a problem when following your guide in this post. The grid shows original text with xml tags such as 222 <i>(Current)</i>, not the result I want 222 (Current). Do I have to enable any property of the grid (except CellDisplayStyle = CellDisplayStyle.FormattedText) to show formatted text?
Hi Boris,
I think I am trying to solve the problem with wrong approach.
The issue is, user wants to have a solid view of data. In other words the solution is to resize the columns width according to the cell data present in all the rows instead of changing the font size of cell (that anyway will not solve this issue), so that the width will be equal to the max. length of the data in any of the cell for that column.
For that I tried PerformAutoResizeColumns, but there we have other issues with this approach:
1. We have one column of type boolean, showing the cell as checkbox, hidden by default. On some action we unhide that column. But when I apply PerformAutoResize that column is still hidden.
2. After applying PerformAutoResize, the data in some of columns is chopped off.
Will appreciate if you can suggest anything on this?
Thanks,
Nitin Jain
Hello Nitin,
Did you try the different overloads of this method?
If you use it this way:
e.Layout.Bands[0].PerformAutoResizeColumns(false, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.VisibleRows, Infragistics.Win.UltraWinGrid.AutoResizeColumnWidthOptions.IncludeCells);.
It should NOT take into account the hidden cells and should autosize to width only by the cell's contents.
If this does not help, please attach a screenshot of the issue after using this code so I can take a look, something might come up on my mind.
I think I have a different ver. of Infragistics (//Infragistics ver. 8.3) as I have only 2 overloads for this function:
PerformAutoResizeColumns(bool sizeHiddenColumns,PerformAutoSizeType performAutoSizeType)
PerformAutoResizeColumns(bool sizeHiddenColumns,PerformAutoSizeType performAutoSizeType,bool includeHeader)
Hi,
So, isn't it working with (false, VisibleRows, false)? Could you please post a sample project which reproduces it, I am not sure how it behaves in v8.3 in your scenario. There should be a way to get the desired behavior even in v8.3, I am determined to find it, just need a project to work on.
I apologies, I cannot provide a sample as Infragistics is on client machine and I do not have permissions to upload any document from there.
1. If I use the (false,VisibleRows,true), some data is chopped off that would be annoying for user.
2. If I use (false,VisibleRows,false), and there is no data in the grid then the display is very weird, it resize all the columns to almost 0 size.
3. If I use (true,VisibleRows,true/false), the hidden columns don't appear again.
Thank you for the feedback.
My answer will be marked by my superior.
Could you please create new threads(questions), it would be easier for me to follow them and it will improve our search functionality for the other community members. Thank you in advance. Please let me know if something comes up!
In my app that column is hidden by default. But I think I can overcome this issue by applying this resize whenever the hidden property changes for that column.
I am not able to mark your post as answer so that it will be useful for others too, may be because this is not my post initially.
Nitin,
This is how it looks in my sample, I also attached the sample itself, the version is 8.3:
Thanks for the sample.
I applied the changes in my code and there is an issue:
The first column which is of boolean type and is showing a checkbox is distorted (Please see snapshot)
Wondering even after passing the last param as true why this is happening.
The following approach works just fine for me:
foreach (UltraGridColumn col in ultraGrid1.DisplayLayout.Bands[0].Columns) col.Width = col.CalculateAutoResizeWidth(PerformAutoSizeType.VisibleRows, true);
Please take a look at the sample attached to this post. If it does not work for you, please modify my sample so it reproduces the issue and send it back to me. I will be happy to take a look at it.