Hi experts,
I have a ControlContainterTool in ribbon group, and I set the CCT's control equals to a ComboEditor. And I set CCT's caption to a certain value, saying "Demo:", so that CCT shows it's caption and a ComboEditor at caption's right side.
The problem is if I add whitespace right side the caption, saying "Demo: ", the whitespace will be trimmed. My goal is to put some spaces between caption and comboEditor, so that they are not too close to each other. Is there any way to preserve those right side whitespaces?
Thanks!
Thanks for your great support. mark as answer.
Hello Ming,
That happens because of the alignment of the text (its default value is “Center”). You can change that by adding the following line in the Load() event of your form:
ultraToolbarsManager1.Tools[“ControlContainerKey”].SharedProps.AppearancesLarge.Appearance.TextHAlign = HAlign.Left;
or you could change the “if(….)” clause in the AfterCreateChildElements method of the “CustomCreationFilter” class by adding el.TextHAlign = HAlign.Left; :
if (parent is ControlContainerToolUIElement)
{
TextUIElement el = (TextUIElement)parent.GetDescendant(typeof(TextUIElement));
el.Text = el.Text.Replace(replacedChar, ' ');
el.TextHAlign = HAlign.Left;
}
This result of that adjustment will be “caption____” -> “caption “.
If you have any additional questions don’t hesitate to ask me.
Hi Dimitar,
Thanks for your reply! I tried your example, and find another wired problem. If I replace any char with whitespace, and the replaced char is only on the very right side of that caption, the whitespace will be also added to caption's left side...
my expection is "caption______" ------> "caption ", but the real one is " caption " .
Any ideas?
ThanksMing.
Infragistics Ribbon was built based on the MS Ribbon Guidelines:
http://msdn.microsoft.com/en-us/library/windows/desktop/cc872782.aspx
It is designed is to be as space efficient as possible, so trimming of the ending whitespaces is expected behavior for ControlContainerTool.
In order to achieve your goal you could use IUIElementCreationFilter interface (you can learn more about this interface here: http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.2/CLR4.0/html/Win_Creation_Filter.html). So you could use a “mask” char in your caption, which you will remove with creation filter, please see attached sample.
I will be happy to answer any additional questions you may have.