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?
Nitin,
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.
Hi Boris,
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.
Thanks,
Nitin Jain
This is how it looks in my sample, I also attached the sample itself, the version is 8.3:
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.
Hello Nitin,
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!