本文整理汇总了C#中XCore.ChoiceGroup.GetDisplayProperties方法的典型用法代码示例。如果您正苦于以下问题:C# ChoiceGroup.GetDisplayProperties方法的具体用法?C# ChoiceGroup.GetDisplayProperties怎么用?C# ChoiceGroup.GetDisplayProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.ChoiceGroup
的用法示例。
在下文中一共展示了ChoiceGroup.GetDisplayProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateComboBox
protected ToolStripComboBox CreateComboBox(ChoiceGroup choice, bool wantsSeparatorBefore)
{
UIItemDisplayProperties display = choice.GetDisplayProperties();
string label = display.Text;
choice.PopulateNow();
if (label == null)
label = AdapterStrings.ErrorGeneratingLabel;
if (!display.Visible)
return null;
label = label.Replace("_", "&");
ToolStripComboBox combo = new ToolStripComboBox();
combo.Text = label;
//foreach(ChoiceBase s in choice)
//{
// item.Items.Add(s.Label);
//}
//item.Tag = choice;
choice.ReferenceWidget = combo;
combo.Tag = choice;
FillCombo(choice);
combo.SelectedIndexChanged += new EventHandler(OnSelectedIndexChanged);
combo.Enabled = display.Enabled;
combo.Visible = display.Visible;
return combo;
}
示例2: FillCombo
/// <summary>
/// populate a combo box on the toolbar
/// </summary>
/// <param name="choice">The group that is the basis for this combo box.</param>
private void FillCombo(ChoiceGroup choice)
{
UIItemDisplayProperties groupDisplay = choice.GetDisplayProperties();
ToolStripComboBox combo = choice.ReferenceWidget as ToolStripComboBox;
if (combo.Focused)
return;//don't mess while we're in the combo
// Disable if needed, but still show what's current, as for unicode fields where you can't change it, but you want to see what it is set to.
combo.Enabled = groupDisplay.Enabled;
ArrayList newItems = new ArrayList();
bool fDifferent = false;
var selectedItem = (ChoiceBase) null;
foreach (ChoiceRelatedClass item in choice)
{
if (item is SeparatorChoice)
{
//TODO
}
else if (item is ChoiceBase)
{
newItems.Add(item);
//if (groupDisplay.Checked)
// selectedItem = (ChoiceBase) item;
if (choice.SinglePropertyValue == (item as ListPropertyChoice).Value)
selectedItem = (ChoiceBase) item;
if (combo.Items.Count < newItems.Count || combo.Items[newItems.Count - 1] != item)
fDifferent = true;
}
}
// let it take the default
// combo.AccessibleName = choice.Label;
if (fDifferent || selectedItem != (combo.SelectedItem))
{
//combo.Click -= new EventHandler(OnComboClick); //don't generate clicks (which end up being onpropertychanged() calls)
combo.Items.Clear();
combo.Items.AddRange(newItems.ToArray());
combo.DropDownStyle = ComboBoxStyle.DropDownList;
combo.SelectedItem = selectedItem;
//combo.SuspendLayout = false;
}
////Set the ComboWidth of the combo box so that is is wide enough to show
////the text of all items in the list.
//int maxStringLength = 0;
//for (int i = 0; i < combo.Items.Count; i++)
//{
// if (combo.Items[i].ToString().Length > maxStringLength)
// {
// maxStringLength = combo.Items[i].ToString().Length;
// }
//}
//int factor = 6;
//if (maxStringLength > 0 && combo.ComboWidth < maxStringLength * factor)
// combo.ComboWidth = maxStringLength * factor;
//combo.Tooltip = combo.ToString();
}
示例3: FillCombo
/// <summary>
/// populate a combo box on the toolbar
/// </summary>
/// <param name="group">The group that is the basis for this combo box.</param>
private void FillCombo(ChoiceGroup group)
{
UIItemDisplayProperties groupDisplay = group.GetDisplayProperties();
ComboBoxItem combo = group.ReferenceWidget as ComboBoxItem;
if(combo.Focused)
return;//don't mess while we're in the combo
// Disable if needed, but still show what's current, as for unicode fields where you can't change it, but you want to see what it is set to.
combo.Enabled = groupDisplay.Enabled;
ArrayList newItems = new ArrayList();
bool fDifferent = false;
ComboItem selectedItem = null;
foreach (ChoiceRelatedClass item in group)
{
if (item is SeparatorChoice)
{
//TODO
}
else if (item is ChoiceBase)
{
UIItemDisplayProperties display = ((ChoiceBase)item).GetDisplayProperties();
ComboItem ci = CreateComboItem((ChoiceBase)item, display);
if (ci != null)//will be null if item is supposed to be invisible now
{
newItems.Add(ci);
if (display.Checked)
{
selectedItem = ci; //nb: if there should be more than one, only the last one will be selected
}
if (combo.Items.Count < newItems.Count || ((combo.Items[newItems.Count - 1]) as ComboItem).Tag != item)
fDifferent = true;
}
}
}
combo.AccessibleName = group.Label;
if (fDifferent || selectedItem.Tag != (combo.SelectedItem as ComboItem).Tag)
{
combo.SuspendLayout = true;
combo.Click -= new EventHandler(OnComboClick); //don't generate clicks (which end up being onpropertychanged() calls)
combo.Items.Clear();
combo.Items.AddRange(newItems.ToArray());
combo.SelectedItem = selectedItem;
combo.Click += new EventHandler(OnComboClick);
combo.SuspendLayout = false;
}
//Set the ComboWidth of the combo box so that is is wide enough to show
//the text of all items in the list.
int maxStringLength = 0;
for (int i = 0; i < combo.Items.Count; i++)
{
if (combo.Items[i].ToString().Length > maxStringLength)
{
maxStringLength = combo.Items[i].ToString().Length;
}
}
int factor = 6;
if (maxStringLength > 0 && combo.ComboWidth < maxStringLength * factor)
combo.ComboWidth = maxStringLength * factor;
combo.Tooltip = combo.ToString();
}