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 Matt
Thanks for your support.
I tried to do so in the method which you suggested but the InitializeRow event gets fired up by the time the grid loads.
I need to have column which is in the grid that updates to the Fonts choosen from another cell in the same grid.
I tried this event in CellChange
Here comes the following code
ultraGrid.DisplayLayout.Override.EditCellAppearance.ForeColor = SystemColors.Desktop;
ultraGrid.DisplayLayout.Override.EditCellAppearance.BackColor = System.Drawing.Color.Black;
After writing this code the ForeColor and BackColor changes for the Active Cell which has focus.
I also tried this too
ultraGrid.Rows[Row].Cells[2].EditorControlResolved.BackColor = System.Drawing.Color.Black;
ultraGrid.Rows[Row].Cells[2].EditorControl.BackColor = System.Drawing.Color.Black;
These two lines throws errors like this
Object reference not set to an instance of an object.
Could you please help me