本文整理汇总了C#中System.Windows.Forms.ComboBox.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.Invoke方法的具体用法?C# ComboBox.Invoke怎么用?C# ComboBox.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ComboBox
的用法示例。
在下文中一共展示了ComboBox.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeComboxBoxSelectedIndex
/// <summary>
/// Invoke方式设置ComboBox控件的SelectedIndex属性
/// </summary>
public static void InvokeComboxBoxSelectedIndex(ComboBox combox, int index)
{
if (combox.InvokeRequired)
{
combox.Invoke(new MethodInvoker(delegate() { InvokeComboxBoxSelectedIndex(combox, index); }));
}
else
{
combox.SelectedIndex = index;
}
}
示例2: ClearItems
public static void ClearItems(ComboBox combobox)
{
MethodInvoker miClearItems = delegate
{
combobox.Items.Clear();
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miClearItems);
}
else
{
miClearItems();
}
}
示例3: AddItem
public static void AddItem(ComboBox combobox, object item)
{
MethodInvoker miAddItem = delegate
{
combobox.Items.Add(item);
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miAddItem);
}
else
{
miAddItem();
}
}
示例4: InsertItem
public static void InsertItem(ComboBox combobox, int index, object item)
{
MethodInvoker miInsertItem = delegate
{
combobox.Items.Insert(index, item);
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miInsertItem);
}
else
{
miInsertItem();
}
}
示例5: RemoveItemAt
public static void RemoveItemAt(ComboBox combobox, int index)
{
MethodInvoker miRemoveItem = delegate
{
combobox.Items.RemoveAt(index);
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miRemoveItem);
}
else
{
miRemoveItem();
}
}
示例6: GetItem
public static object GetItem(ComboBox combobox, int index)
{
object item = null;
MethodInvoker miRemoveItem = delegate
{
item = combobox.Items[index];
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miRemoveItem);
}
else
{
miRemoveItem();
}
return item;
}
示例7: GetSelectedItem
public static object GetSelectedItem(ComboBox combobox)
{
object selectedItem = null;
MethodInvoker miClearItems = delegate
{
selectedItem = combobox.SelectedItem;
};
if (combobox.InvokeRequired)
{
combobox.Invoke(miClearItems);
}
else
{
miClearItems();
}
return selectedItem;
}
示例8: GetSelectedIndexOfComboBox
private int GetSelectedIndexOfComboBox(ComboBox comboBox)
{
if (comboBox.InvokeRequired)
return (int)comboBox.Invoke(new Func<int>(() => GetSelectedIndexOfComboBox(comboBox)));
return comboBox.SelectedIndex;
}
示例9: getDropDownListValue
private string getDropDownListValue(ComboBox ddlName, String columnName)
{
#region Variable
var result = "";
#endregion
#region Procedure
try
{
if (ddlName.InvokeRequired)
{
ddlName.Invoke(new MethodInvoker(delegate
{
try
{
var drv = (DataRowView)ddlName.SelectedItem;
var dr = drv.Row;
try
{
result = dr[columnName].ToString();
}
catch (Exception)
{
result = dr[0].ToString();
}
}
catch (Exception)
{
result = "";
}
}));
}
else
{
try
{
var drv = (DataRowView)ddlName.SelectedItem;
var dr = drv.Row;
try
{
result = dr[columnName].ToString();
}
catch (Exception)
{
result = dr[0].ToString();
}
}
catch (Exception)
{
result = "";
}
}
}
catch (Exception) { }
#endregion
return result;
}
示例10: ComboxBind
/// <summary>
/// combox数据绑定
/// </summary>
/// <param name="comboBox"></param>
/// <param name="data"></param>
private void ComboxBind(ComboBox comboBox, object data)
{
if (comboBox.InvokeRequired)
comboBox.Invoke(new EventsHandlerComboxBind(ComboxBind), comboBox, data);
else
{
var bs = new BindingSource { DataSource = data };
comboBox.DataSource = bs;
comboBox.DisplayMember = "Key";
comboBox.ValueMember = "Value";
comboBox.SelectedIndex = -1;
}
}
示例11: setCbxText
private void setCbxText(ComboBox cbx, string text)
{
if (cbx.InvokeRequired)
{
cbx.Invoke(new void__ComboBox_string(setCbxText), cbx, text);
}
else
{
cbx.Text = text;
}
}
示例12: GetSelectedValue
private object GetSelectedValue(ComboBox cbo)
{
object obj = null;
if (cbo.InvokeRequired)
{
obj = cbo.Invoke((MyDelegate)delegate() { return obj = cbo.SelectedValue; });
return obj;
}
else
{
return obj = cbo.SelectedValue;
}
}
示例13: updateComboBox
private void updateComboBox(ComboBox cmb, string value, bool add)
{
if (cmb.InvokeRequired) { cmb.Invoke(new cmbDelegate(updateComboBox), new object[] { cmb, value, add }); } else {
if (add) { cmb.Items.Add(value); } else { cmb.Items.Clear(); }
}
}
示例14: AddComboboxLine
public void AddComboboxLine(ComboBox Destination, String newText, Int32 position=0, Int32 maxLength=10)
{
if(Destination.InvokeRequired)
Destination.Invoke(new del_AddComboboxLine(AddComboboxLine), Destination, newText, position, maxLength);
else
{
Destination.Items.Insert(position, newText);
Destination.SelectedIndex = 0;
while (Destination.Items.Count > maxLength)
Destination.Items.RemoveAt(Destination.Items.Count-1);
}
}
示例15: readComboBox
private string readComboBox(ComboBox box)
{
return (string)box.Invoke(new ReadComboDelegate(readComboHelper), new object[] { box });
}