I'm trying to bold or highlight single words in a node or cell but have not found any functionality other than changing properties on a node or cell level, which bolds the entire node/cell which is not what I want.
Also I have tried several different ways of word wrapping but nothing seems to work other than in the default view. I am trying to get my text to wrap in the Outlook express view style on a per cell basis but the text seems to just flow off the screen. I have tried setting the CellWrapText property, the AutoSizeMode property, the Multiline property, and have tried increasing the size of the lables/cells to account for the text wrapping but it remains on one line.
Here is the code:
public void BuildTreeTest() { var item1 = new NmfcItemVM(); //var item2 = new NmfcItemVM(); item1.Description = "Explosives, consisting of ammunition, explosive or incendiary, or gas or smoke or tear producing; Explosives, NOI; Propellants, explosive; Blasting Explosives, consisting of ammunition, explosive or incendiary, or gas or smoke or tear producing; Explosives, NOI; Propellants, explosive; Blasting" + "Explosives, consisting of ammunition, explosive or incendiary, or gas or smoke or tear producing; Explosives, NOI; Propellants, explosive; Blasting (ITEM LEVEL DESCRIPTION)"; item1.Id = "YVV00H9W"; item1.Item = "104000"; item1.ItemSub = "00"; var note1 = new NoteVM(); note1.Description = "Note: explosive ITEM LEVEL NOTE"; note1.Id = "103000"; item1.Notes.Add(note1); var pointer1 = new PointerVM(); pointer1.Description = "Pointer parent 2"; pointer1.Item = "105000"; pointer1.ItemSub = "00"; var pointer2 = new PointerVM(); pointer2.Description = "Pointer parent 1"; pointer2.Item = "106000"; pointer2.ItemSub = "02"; item1.Pointers.Add(pointer1); item1.Pointers.Add(pointer2); var sub = new NmfcSubItemVM(); sub.Description = "Nmfc sub item, Chain, iron or steel Nmfc sub item, Chain, iron or steel Nmfc sub item, Chain, iron or steel Nmfc sub item, Chain, iron or steel (SUB LEVEL DESCRIPTION)"; sub.Class = "50"; sub.SubItemNumber = "00"; sub.Item = "107500"; var subNote = new NoteVM(); subNote.Description = "Iron SUB LEVEL NOTE"; subNote.Id = "103455"; sub.Notes.Add(subNote); item1.SubItems.Add(sub);
ItemVms = new List<NmfcItemVM>(); ItemVms.Add(item1);
//BuildTreeTest2(); PopulateSearchTree();
}
public void PopulateSearchTree() { var tree = NmfcSearchView.utNmfc; tree.Nodes.Clear();
// Define the top Level Columns UltraTreeColumnSet commonColumns = new UltraTreeColumnSet(); commonColumns.Columns.Add("Item"); commonColumns.Columns.Add("Description"); commonColumns.Columns.Add("Class"); tree.ColumnSettings.RootColumnSet = commonColumns; tree.ColumnSettings.ColumnHeaderWrapText = DefaultableBoolean.True; commonColumns.Columns["Item"].CanShowExpansionIndicator = DefaultableBoolean.True; commonColumns.Columns["Description"].CellWrapText = DefaultableBoolean.True; commonColumns.ColumnAutoSizeMode = ColumnAutoSizeMode.AllNodesWithDescendants; tree.ViewStyle = ViewStyle.OutlookExpress;
foreach (var itemVM in ItemVms) {
int pointerCount = itemVM.Pointers.Count; var pointerNodeSub = new UltraTreeNode(); var pointerNodeSub2 = new UltraTreeNode(); var itemNode = new UltraTreeNode(); var topPointer = new PointerVM(); var topNode = new UltraTreeNode(); var noteNode = new UltraTreeNode(); if (pointerCount > 0) { topPointer = itemVM.Pointers[pointerCount - 1]; topNode = tree.Nodes.Add(topPointer.Item + topPointer.ItemSub + topPointer.Description); topNode.Cells["Item"].Value = topPointer.Item; topNode.Cells["Description"].Value = topPointer.Description; } //3 pointers if (pointerCount > 2) { PointerVM subPointer = itemVM.Pointers[pointerCount - 2]; pointerNodeSub = topNode.Nodes.Add(subPointer.Item + subPointer.ItemSub + subPointer.Description); pointerNodeSub.Cells["Item"].Value = subPointer.Item; pointerNodeSub.Cells["Description"].Value = subPointer.Description;
PointerVM subPointer2 = itemVM.Pointers[pointerCount - 3]; pointerNodeSub2 = pointerNodeSub.Nodes.Add(subPointer2.Item + subPointer2.ItemSub + subPointer2.Description); pointerNodeSub2.Cells["Item"].Value = subPointer2.Item; pointerNodeSub2.Cells["Description"].Value = subPointer2.Description; itemNode = pointerNodeSub2.Nodes.Add(itemVM.Item + itemVM.ItemSub + itemVM.Description); itemNode.Cells["Item"].Value = itemVM.Item; itemNode.Cells["Description"].Value = itemVM.Description; } //2 pointers else if (pointerCount > 1) { PointerVM subPointer = itemVM.Pointers[pointerCount - 2]; pointerNodeSub = topNode.Nodes.Add(subPointer.Item + subPointer.ItemSub + subPointer.Description); pointerNodeSub.Cells["Item"].Value = subPointer.Item; pointerNodeSub.Cells["Description"].Value = subPointer.Description; itemNode = pointerNodeSub.Nodes.Add(itemVM.Item + itemVM.ItemSub + itemVM.Description); itemNode.Cells["Item"].Value = itemVM.Item; itemNode.Cells["Description"].Value = itemVM.Description; } //1 pointer else if (pointerCount > 0) { itemNode = topNode.Nodes.Add(itemVM.Item + itemVM.ItemSub + itemVM.Description); itemNode.Cells["Item"].Value = itemVM.Item; itemNode.Cells["Description"].Value = itemVM.Description; } //No pointers else { itemNode = tree.Nodes.Add(itemVM.Item + itemVM.ItemSub + itemVM.Description); itemNode.Cells["Item"].Value = itemVM.Id; itemNode.Cells["Description"].Value = itemVM.Description; }
//item notes foreach (var note in itemVM.Notes) { if (pointerCount > 2) { noteNode = pointerNodeSub2.Nodes.Add(note.Id + " " + note.Description); noteNode.Cells["Item"].Value = note.Id; noteNode.Cells["Description"].Value = note.Description; } else if (pointerCount > 1) { noteNode = pointerNodeSub.Nodes.Add(note.Id + " " + note.Description); noteNode.Cells["Item"].Value = note.Id; noteNode.Cells["Description"].Value = note.Description; } else if (pointerCount > 0) { noteNode = topNode.Nodes.Add(note.Id + " " + note.Description); noteNode.Cells["Item"].Value = note.Id; noteNode.Cells["Description"].Value = note.Description; } else { noteNode = tree.Nodes.Add(note.Id + " " + note.Description); noteNode.Cells["Item"].Value = note.Id; noteNode.Cells["Description"].Value = note.Description; } }
//sub items foreach (var subItem in itemVM.SubItems) { var subNode = new UltraTreeNode(); if (itemVM.Notes.Count > 0) { subNode = noteNode.Nodes.Add("Sub " + subItem.SubItemNumber + subItem.Description + subItem.Class); subNode.Cells["Item"].Value = subItem.Item; subNode.Cells["Description"].Value = subItem.Description; subNode.Cells["Class"].Value = subItem.Class; tree.ActiveNode = subNode; //sub item notes foreach (var subNote in subItem.Notes) { noteNode = noteNode.Nodes.Add(subNote.Id + " " + subNote.Description); noteNode.Cells["Item"].Value = subNote.Id; noteNode.Cells["Description"].Value = subNote.Description; tree.ActiveNode = noteNode; } } else { subNode = itemNode.Nodes.Add("Sub " + subItem.SubItemNumber + subItem.Description + subItem.Class); subNode.Cells["Item"].Value = subItem.Item; subNode.Cells["Description"].Value = subItem.Description; subNode.Cells["Class"].Value = subItem.Class; tree.ActiveNode = subNode; //sub item notes foreach (var subNote in subItem.Notes) { noteNode = itemNode.Nodes.Add(subNote.Id + " " + subNote.Description); noteNode.Cells["Item"].Value = subNote.Id; noteNode.Cells["Description"].Value = subNote.Description; tree.ActiveNode = noteNode; } }
} }
Tree Image:
Hi Quinn,
You should be able to accomplish this by using an UltraFormattedTextEditor as the editor for the Description column. You can read about using embeddable editors with UltraTree in our documentation.
I believe that UltraFormattedTextEditor will provide all the options you need. Please try it out and let me know whether it works for you.
I figured out how to dynamically change the text using the UltraFormattedTextEditor like you said by doing something like this:
var ufte = new UltraFormattedTextEditor();var testPig = itemVM.Description;var som = testPig.Replace("explosive", "<span style=\"color: Red;\">explosive</span>");ufte.Value = som;ufte.WrapText = true;itemNode.Cells["Item"].Value = itemVM.Item;itemNode.Cells["Description"].EditorComponent = ufte;itemNode.Cells["Description"].Value = ufte.Value; //itemVM.Description;itemNode.Cells["Description"].Column.CellWrapText = DefaultableBoolean.True;
However I can't figure out what value to change to set the cell's height to account for the text wrapping, currently it appears on one line with arrows. I have tried overriding the ItemHeight and MaxLabelHeight on the node but that doesn't seem to work: the size increases but the text still stays on one line with arrows. Any suggestions? thanks.
Picture: