Hi,
I am having a different kind of requirement.
I have two lines of text in a single cell in Ultrawingrid.
I have to apply font size of 14 and color black to first line text.
And font size of 12 and color blue to second line text.
Could you please let me know how to do it?
Thanks,
Venkat.
Hi Venkat,
You could set the Style of the column to FormattedText. And then use XML as the Value of the cell to control the formatting. The custom XML format used by a FormattedText cell in the grid is the same one used by the UltraFormattedLinkLabel or UltraFormattedTextEditor controls.
i have used e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay into ultraGrid_InitializeRow event. Then how i can use two different font sizes for the text of the same cell?
pls let me know if any options avail.
Mosam
Hi Mike,
Below is my method for customize cell format.
i have added below code to add "My Test" text in each cell's existing value which requires to be added with 5.25pt font size. and other existing text should remain with existing font size 9pt.
e.Row.Cells[i].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText;e.Row.Cells[i].Value = e.Row.Cells[i].Value + "<font size=\"5.25pt\">\n My Test</font>";
But "My Test" is not getting added properly for each cell and display like below,
private void uGrid_InitializeRow(object sender, InitializeRowEventArgs e) { UltraGridBand m_band = e.Row.Band; try { for (int i = 1; i < m_band.Columns.Count - (CintColumnsToHide - 1); i++) { string myValue = (string)e.Row.Cells[i].Value;
e.Row.Cells[i].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText; e.Row.Cells[i].Value = e.Row.Cells[i].Value + "<font size=\"5.25pt\">\n My Test</font>"; \\My Test should be shown with smaller font in new line
string abCode = (string)e.Row.Cells[i + 2].Value; string strHasRHistory = (string)e.Row.Cells[i + 4].Value.ToString().ToUpper(); bool isFullEditorDisplay = true;
switch abCode ()) { case "M": e.Row.Cells[i].Appearance.Image = ImageServer.GetImage("RH"); e.Row.Cells[i].Appearance.ImageHAlign = HAlign.Right; e.Row.Cells[i].Appearance.ImageVAlign = VAlign.Top; e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay; break; case "N": e.Row.Cells[i].Appearance.Image = ImageServer.GetImage("RL"); e.Row.Cells[i].Appearance.ImageHAlign = HAlign.Right; e.Row.Cells[i].Appearance.ImageVAlign = VAlign.Top; e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay; break; default: //e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FormattedText; isFullEditorDisplay = false; break; }
if strHasRHistory == "TRUE" ) { UltraTextEditor uViewHistoryTextEditor = new UltraTextEditor(); if (strHasResultCorrectionHistory == "TRUE") { } EditorButton btnViewHisEditor = new EditorButton(); btnViewHisEditor.AccessibleName = "btnhasRHistory"; btnViewHisEditor.Tag = "btnhasRHistory"; btnViewHisEditor.Appearance.Image = ImageServer.GetImage("History"); btnViewHisEditor.Appearance.ImageHAlign = HAlign.Right; btnViewHisEditor.Appearance.ImageVAlign = VAlign.Top; btnViewHisEditor.ButtonStyle = UIElementButtonStyle.Borderless; btnViewHisEditor.Appearance.BackColor = Color.Transparent; uViewHistoryTextEditor.ButtonsRight.AddbtnViewHisEditor
e.Row.Cells[i].EditorComponent = uViewHistoryTextEditor; e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay; _uResultGrid.DisplayLayout.Bands[0].Columns[i].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; } else { if (isFullEditorDisplay == false) { e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FormattedText; } }
// Column Width should be increased if Comments Text Length is more than 8 characters.. if (e.Row.Cells[i].Text.Length > 8) { m_band.Columns[i].CellMultiLine = DefaultableBoolean.True; m_band.Columns[i].Width = 200; } e.Row.PerformAutoSize(); // Auto resize row once value assigned to row... i += (CintColumnsToHide - 1); } } catch (Exception ex) { } }
Pls provide your suggestion on this
Hi Mosam,
The problem is that the existing text has reserved characters in it, so it's failing to parse as valid Xml. Since you are now using FormattedText, the value of the cell is Xml, and so you have to be careful about using certain characters that have special meaning in Xml like "<" and ">". If I assign a value to the cell like: "<span style=\"font-size:5.25pt;\">My Tes</span>"Then that works fine. But your text contains "<Dispose Item>" before that, and that's not a valid Xml tag and even if it were, it has no closing tag. So you will need to escape those "<" and ">" signs to make them show up as literals. So this does not work: "<Dispense Item> <span style=\"font-size:5.25pt;\">Text2</span>"But this will: "<Dispense Item> <span style=\"font-size:5.25pt;\">Text2</span>"
above solution would resolves the issue for "<" such text coming into text xml but if you have observed in above method, in same cell - we are trying to add text as well as image and button also. whenever in cell, if image or button also gets added then again it doesn't take text as xml and display like below. See in below wherever, no button in cell then xml text displays properly but not in second row when it has button in top right corner.
Can you pls suggest some solution which could work in both scenario.
Thanks
Oh... you are setting the EditorComponent to an UltraTextEditor. Instead of that, use an UltraFormattedTextEditor. Setting the Style on the column changes the default editor. But if you then set the EditorComponent, you are essentially ignoring the Style and overriding the editor. So you can forego setting the Style in this case and just use an UltraFormattedTextEditor as an EditorComponent and achieve the same thing. UltraFormattedTextEditor also supports Editor buttons, so you can add the same button to it that you are adding to your UltraTextEditor.
Thanks for providing suggestions on it. I have set the EditorComponent to UltraFormattedTextEditor from UltraTextEditor. It shows button named H in upper right side. but issue is with images when e.Row.Cells[i].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText. Its not showing images in same cell.
Also, i don't want to use xml option to show formatted two different texts in same cell along with image and button within same cell.
Is there any other approach where i can display two different formats of text values having different font sizes along with image and button in same cell.
We don't want to use xml approach as we may have certain data value which may be conflicting while converting them to xml.
Is there any way to add different format text value(eg. having different font than existing cell text) in some control and that would be further added into cell. After that, it would be displayed along with existing text value of the cell and that cell also having existing image and existing button within.
below is simple code where its displaying text plus button plus image in same cell. Where i need to add another formatted text value within.
Can you pls provide your inputs here.
private void uGrid_InitializeRow(object sender, InitializeRowEventArgs e)
{
UltraGridBand m_band = e.Row.Band;
try
for (int i = 1; i < m_band.Columns.Count - (CintColumnsToHide - 1); i++)
string myValue = (string)e.Row.Cells[i].Value;
//e.Row.Cells[i].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText;
//e.Row.Cells[i].Value = e.Row.Cells[i].Value + "<font size=\"5.25pt\">\n My Test</font>"; \\My Test should be shown with smaller font in new line
string abCode = (string)e.Row.Cells[i + 2].Value;
string strHasRHistory = (string)e.Row.Cells[i + 4].Value.ToString().ToUpper();
bool isFullEditorDisplay = true;
switch abCode ())
case "M":
e.Row.Cells[i].Appearance.Image = ImageServer.GetImage("RH");
e.Row.Cells[i].Appearance.ImageHAlign = HAlign.Right;
e.Row.Cells[i].Appearance.ImageVAlign = VAlign.Top;
e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay;
break;
case "N":
e.Row.Cells[i].Appearance.Image = ImageServer.GetImage("RL");
default:
//e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FormattedText;
isFullEditorDisplay = false;
}
if strHasRHistory == "TRUE" )
UltraTextEditor uViewHistoryTextEditor = new UltraTextEditor();
if (strHasResultCorrectionHistory == "TRUE")
} EditorButton btnViewHisEditor = new EditorButton();
btnViewHisEditor.AccessibleName = "btnhasRHistory";
btnViewHisEditor.Tag = "btnhasRHistory";
btnViewHisEditor.Appearance.Image = ImageServer.GetImage("History");
btnViewHisEditor.Appearance.ImageHAlign = HAlign.Right;
btnViewHisEditor.Appearance.ImageVAlign = VAlign.Top;
btnViewHisEditor.ButtonStyle = UIElementButtonStyle.Borderless;
btnViewHisEditor.Appearance.BackColor = Color.Transparent;
uViewHistoryTextEditor.ButtonsRight.AddbtnViewHisEditor
e.Row.Cells[i].EditorComponent = uViewHistoryTextEditor;
_uResultGrid.DisplayLayout.Bands[0].Columns[i].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always;
else
if (isFullEditorDisplay == false)
e.Row.Cells[i].CellDisplayStyle = CellDisplayStyle.FormattedText;
// Column Width should be increased if Comments Text Length is more than 8 characters..
if (e.Row.Cells[i].Text.Length > 8)
m_band.Columns[i].CellMultiLine = DefaultableBoolean.True;
m_band.Columns[i].Width = 200;
e.Row.PerformAutoSize(); // Auto resize row once value assigned to row...
i += (CintColumnsToHide - 1);
catch (Exception ex)
I'm not sure what kind of images you are referring to. But at a guess, you might be applying an image to the Cell via an Appearance, and I don't think the FormattedTextEditor provides the ability to show image and text separately like that. You could embed the image into the Xml, of course, as I mentioned earlier. There's an Image tag and a whole bunch of options for that. If you don't want to use the Xml approach at all, then the other alternative would be to use a DrawFilter or a essentially draw the cell (or the cell text) yourself. If you are familiar with GDI Plus drawing and text rendering, then that might be a better alternative, since it would mean you could keep using UltraTextEditor. The down side is that since you would be affecting the cell contents at the Drawing level, things like sorting and AutoSizing the column wouldn't be able to account for that. And the text would not display when the cell is in edit mode - if you are even allowing the user to edit this cell, which seems unlikely.
You could use the UltraControlContainerEditor to place a control in a cell. So, you could, for example, create a control that has two textboxes or a textbox and a label or something like so that you display two pieces of information in the cell with different fonts or formatting. But there are a few caveats to be aware of with this approach: - First, the cell itself only contains a single value. So you would need to either parse that value or get the additional data from somewhere else. - Second, it can be a bit tricky to set up the UltraControlContainerEditor if you've never done it before, so you'd have to check the documentation and samples on how to do it correctly.
Can you pls provide some sample where multiple texts , image and button controls are getting added in same cell using UltraControlContainerEditor.
I have gone through some of the examples like below where per cell - only one control is shown how to be added.
https://www.infragistics.com/help/winforms/wincontrolcontainereditor-embed-any-control-within-wingrid-cell-using-ultracontrolcontainereditor-component
A cell can only contain a single value. So you would need to work out how to break up a single value into multiple pieces of text. There are an number of ways you could do this, but it would depend a lot on what your data is on how it relates to the other pieces of data.You could use a delimited string of some kind, for example. Of you could have a column your grid that is some kind of object with multiple properties on it. The challenge in that case would be how to relate that object to your database/back end - assuming it even has a back end and isn't just run-time data. Regarding placing multiple controls in a cell, the UltraControlContainerEditor has ONE RenderingControl and ONE EditingControl. But you could create a control or a UserControl that is contains several over controls, like a couple of TextBoxes, for example. You still have to handle everything through a SINGLE property, but again, that property could be a delimited string which then gets parsed into the separate TextBoxes and re-combined. Or it could be an object with multiple properties on it. I don't think we have any samples of this on-hand. And it would be tricky to set up, quite frankly. There's a lot of infrastructure you would need to handle like INotifyPropertyChange on both the object and it's sub-objects. It's really hard for me to guide you here without knowing a lot more about exactly what you are trying to achieve, what the data is, how the different pieces of the data relate to each, etc.