本文整理汇总了C#中System.Windows.Forms.ComboBox.BeginUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.BeginUpdate方法的具体用法?C# ComboBox.BeginUpdate怎么用?C# ComboBox.BeginUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ComboBox
的用法示例。
在下文中一共展示了ComboBox.BeginUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadExt
private static void LoadExt( string a, ComboBox b )
{
b.BeginUpdate();
try {
b.Items.Clear();
var exts = GetAppForExt( a );
b.Items.AddRange( exts );
var current = Ext.GetCurrentProgID( a );
b.Items.Add( "None" );
if ( current != null ) {
if ( !exts.Any( x => x.Name.Replace( " ", "." ) == current ) ) {
b.Items.Add( "Other" );
b.SelectedIndex = b.Items.Count - 1;
}
else
b.SelectedItem = b.Items.OfType<App>().First( x => x.Name.Replace( " ", "." ) == current );
}
else {
b.SelectedIndex = b.Items.Count - 1;
}
}
catch ( Exception ex ) {
Console.WriteLine( ex.Message );
}
b.EndUpdate();
}
示例2: PopulateAnalyzers
internal void PopulateAnalyzers(ComboBox cbAnalyzers)
{
cbAnalyzers.BeginUpdate();
cbAnalyzers.Items.Clear();
cbAnalyzers.Items.AddRange(Analyzing.GetAnalyzerNames().ToArray());
cbAnalyzers.EndUpdate();
}
示例3: Populate
/// <summary>
/// Clears and fills the control with the given data.
/// </summary>
/// <param name="ctrl">Combobox control to fill</param>
/// <param name="data">List of data</param>
/// <param name="none">Flag to fill the first position with "None"</param>
/// <remarks>Painting is suspended until after items have been added</remarks>
public static void Populate(ComboBox ctrl, IList<dynamic> data, bool none)
{
ctrl.BeginUpdate();
ctrl.Items.Clear();
if (none)
ctrl.Items.Add("<None>");
for (int i = 1; i < data.Count; i++)
ctrl.Items.Add(data[i].ToString());
ctrl.EndUpdate();
}
示例4: BuildNamespacesList
public static bool BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection)
{
if (help2Collections == null)
{
throw new ArgumentNullException("help2Collections");
}
HxRegistryWalkerClass registryWalker;
IHxRegNamespaceList help2Namespaces;
try
{
registryWalker = new HxRegistryWalkerClass();
help2Namespaces = registryWalker.get_RegisteredNamespaceList("");
}
catch (System.Runtime.InteropServices.COMException)
{
help2Namespaces = null;
registryWalker = null;
}
if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0)
{
return false;
}
help2Collections.Items.Clear();
help2Collections.BeginUpdate();
try
{
string currentDescription = string.Empty;
foreach (IHxRegNamespace currentNamespace in help2Namespaces)
{
help2Collections.Items.Add
((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription));
if (!string.IsNullOrEmpty(selectedHelp2Collection) &&
string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
{
currentDescription =
(string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
}
}
if (!string.IsNullOrEmpty(currentDescription))
help2Collections.SelectedIndex = help2Collections.Items.IndexOf(currentDescription);
else
help2Collections.SelectedIndex = 0;
}
finally
{
help2Collections.EndUpdate();
}
return true;
}
示例5: SetListItems
public static void SetListItems(ComboBox comboBox, ListItemWithId[] items)
{
comboBox.Text = "";
comboBox.Items.Clear();
comboBox.BeginUpdate();
for (int i = 0; i < items.Length; i++)
comboBox.Items.Add(items[i]);
comboBox.EndUpdate();
}
示例6: UpdateList
public static void UpdateList(ComboBox comboBox, SelectableListNodeList items)
{
comboBox.SelectedIndexChanged -= EhComboBoxSelectionChanged;
comboBox.BeginUpdate();
comboBox.Items.Clear();
for (int i = 0; i < items.Count; i++)
{
comboBox.Items.Add(items[i]);
if (items[i].Selected)
comboBox.SelectedIndex = i;
}
comboBox.EndUpdate();
comboBox.SelectedIndexChanged += EhComboBoxSelectionChanged;
}
示例7: Popola
/// <summary>
///
/// </summary>
/// <param name="comboBox"></param>
/// <param name="lista"></param>
public static void Popola(ref ComboBox comboBox, object lista, string DisplayMember, string ValueMember)
{
comboBox.BeginUpdate();
comboBox.Items.Clear();
// List<TipoUtensile> tipiUtensili = new TipoUtensileDao(MyApplication.GetConnection()).ListaOrdinata();
if (lista != null)
{
comboBox.DataSource = lista;
comboBox.DisplayMember = DisplayMember;
comboBox.ValueMember = ValueMember;
}
comboBox.EndUpdate();
}
示例8: LoadRemotes
protected void LoadRemotes(GitClient client, ComboBox remoteBox)
{
var config = client.GetConfig(RepositoryPath);
var currentBranch = client.GetCurrentBranch(RepositoryPath);
string currentBranchRemote = config.GetString("branch", currentBranch.ShortName, "remote");
remoteBox.BeginUpdate();
remoteBox.Items.Clear();
foreach (string remote in config.GetSubsections("remote"))
{
remoteBox.Items.Add(remote);
if (remote == currentBranchRemote)
remoteBox.SelectedIndex = remoteBox.Items.Count - 1;
}
remoteBox.EndUpdate();
}
示例9: InitializeSubtitleFormatComboBox
public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, IEnumerable<string> formatNames, string selectedName)
{
var selectedIndex = 0;
comboBox.BeginUpdate();
comboBox.Items.Clear();
using (var graphics = comboBox.CreateGraphics())
{
var maxWidth = 0.0F;
foreach (var name in formatNames)
{
var index = comboBox.Items.Add(name);
if (name.Equals(selectedName, StringComparison.OrdinalIgnoreCase))
selectedIndex = index;
var width = graphics.MeasureString(name, comboBox.Font).Width;
if (width > maxWidth)
maxWidth = width;
}
comboBox.DropDownWidth = (int)Math.Round(maxWidth + 7.5);
}
comboBox.SelectedIndex = selectedIndex;
comboBox.EndUpdate();
}
示例10: InitializeComboBox
void InitializeComboBox(ComboBox box, SelectableListNodeList list)
{
box.BeginUpdate();
box.Items.Clear();
for (int i = 0; i < list.Count; i++)
{
SelectableListNode node = list[i];
box.Items.Add(node);
if (node.Selected)
box.SelectedIndex=i;
}
box.EndUpdate();
}
示例11: UpdateCountryComboBox
/// <summary>
/// 国家コンボボックスを更新する
/// </summary>
/// <param name="control">コントロール</param>
/// <param name="allowEmpty">空項目を許可するかどうか</param>
private void UpdateCountryComboBox(ComboBox control, bool allowEmpty)
{
Graphics g = Graphics.FromHwnd(Handle);
int margin = DeviceCaps.GetScaledWidth(2) + 1;
int width = control.Width;
control.BeginUpdate();
control.Items.Clear();
if (allowEmpty)
{
control.Items.Add("");
}
foreach (Country country in Countries.Tags)
{
string s = Countries.GetTagName(country);
control.Items.Add(s);
width = Math.Max(width,
(int) g.MeasureString(s, control.Font).Width + SystemInformation.VerticalScrollBarWidth + margin);
}
control.DropDownWidth = width;
control.EndUpdate();
}
示例12: LoadItemsIntoComboBox
private void LoadItemsIntoComboBox( ComboBox combobox, IEnumerable<object> items )
{
combobox.BeginUpdate();
foreach( var item in items )
combobox.Items.Add(item);
combobox.EndUpdate();
}
示例13: BeginEndUpdateTest
public void BeginEndUpdateTest ()
{
Form myform = new Form ();
myform.ShowInTaskbar = false;
myform.Visible = true;
ComboBox cmbbox = new ComboBox ();
cmbbox.Items.Add ("A");
cmbbox.Visible = true;
myform.Controls.Add (cmbbox);
cmbbox.BeginUpdate ();
for (int x = 1 ; x < 5000 ; x++) {
cmbbox.Items.Add ("Item " + x.ToString ());
}
cmbbox.EndUpdate ();
myform.Dispose ();
}
示例14: UpdateListItems
/// <summary>
/// リスト項目の値を更新する
/// </summary>
/// <param name="control">コントロール</param>
/// <param name="unit">ユニット</param>
public void UpdateListItems(ComboBox control, Unit unit)
{
control.BeginUpdate();
control.Items.Clear();
ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag;
switch (itemId)
{
case ScenarioEditorItemId.UnitLocation:
case ScenarioEditorItemId.UnitBase:
List<Province> provinces = (List<Province>) GetListItems(itemId, unit);
if (provinces != null)
{
foreach (Province province in provinces)
{
ProvinceSettings settings = Scenarios.GetProvinceSettings(province.Id);
control.Items.Add(Scenarios.GetProvinceName(province, settings));
}
}
break;
case ScenarioEditorItemId.UnitLeader:
List<Leader> leaders = (List<Leader>) GetListItems(itemId, unit);
foreach (Leader leader in leaders)
{
control.Items.Add(leader.Name);
}
break;
}
control.EndUpdate();
}
示例15: FormField
public FormField(Field f, XDataForm form, int tabIndex)
{
m_field = f;
m_type = f.Type;
m_var = f.Var;
m_val = f.Vals;
m_required = f.IsRequired;
m_form = form;
Panel p = null;
if (m_type != FieldType.hidden)
{
p = new Panel();
p.Parent = m_form.pnlFields;
p.TabIndex = tabIndex;
}
switch (m_type)
{
case FieldType.hidden:
break;
case FieldType.boolean:
CheckBox cb = new CheckBox();
cb.Checked = f.BoolVal;
cb.Text = null;
m_control = cb;
break;
case FieldType.text_multi:
TextBox mtxt = new TextBox();
mtxt.Multiline = true;
mtxt.ScrollBars = ScrollBars.Vertical;
mtxt.Lines = m_val;
mtxt.Height = m_form.btnOK.Height * 3;
m_control = mtxt;
break;
case FieldType.text_private:
TextBox ptxt = new TextBox();
ptxt.Lines = m_val;
ptxt.PasswordChar = '*';
m_control = ptxt;
break;
case FieldType.list_single:
ComboBox box = new ComboBox();
box.DropDownStyle = ComboBoxStyle.DropDownList;
box.BeginUpdate();
string v = null;
if (m_val.Length > 0)
v = m_val[0];
foreach (Option o in f.GetOptions())
{
int i = box.Items.Add(o);
if (o.Val == v)
{
box.SelectedIndex = i;
}
}
box.EndUpdate();
m_control = box;
break;
case FieldType.list_multi:
//ListBox lb = new ListBox();
CheckedListBox lb = new CheckedListBox();
//lb.SelectionMode = SelectionMode.MultiExtended;
lb.VisibleChanged += new EventHandler(lb_VisibleChanged);
m_control = lb;
break;
case FieldType.jid_single:
TextBox jtxt = new TextBox();
jtxt.Lines = m_val;
jtxt.Validating += new CancelEventHandler(jid_Validating);
jtxt.Validated += new EventHandler(jid_Validated);
m_control = jtxt;
m_form.error.SetIconAlignment(m_control, ErrorIconAlignment.MiddleLeft);
break;
case FieldType.jid_multi:
JidMulti multi = new JidMulti();
multi.AddRange(m_val);
m_control = multi;
break;
case FieldType.Fixed:
// All of this so that we can detect URLs.
// We can't just make it disabled, because then the URL clicked
// event handler doesn't fire, and there's no way to set the
// text foreground color.
// It would be cool to make copy work, but it doesn't work for
// labels, either.
RichTextBox rich = new RichTextBox();
rich.DetectUrls = true;
rich.Text = string.Join("\r\n", f.Vals);
rich.ScrollBars = RichTextBoxScrollBars.None;
rich.Resize += new EventHandler(lbl_Resize);
rich.BorderStyle = BorderStyle.None;
rich.LinkClicked += new LinkClickedEventHandler(rich_LinkClicked);
rich.BackColor = System.Drawing.SystemColors.Control;
rich.KeyPress += new KeyPressEventHandler(rich_KeyPress);
//.........这里部分代码省略.........