本文整理汇总了C#中System.Windows.Forms.CheckedListBox.BeginUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.BeginUpdate方法的具体用法?C# CheckedListBox.BeginUpdate怎么用?C# CheckedListBox.BeginUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.BeginUpdate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public static void Draw( CheckedListBox list )
{
list.BeginUpdate();
list.Items.Clear();
for (int i=0;i<m_Filters.Count;i++)
{
Filter f = (Filter)m_Filters[i];
list.Items.Add( f );
list.SetItemChecked( i, f.Enabled );
}
list.EndUpdate();
}
示例2: EditValue
/// <summary>
/// Overrides the method used to provide basic behaviour for selecting editor.
/// Shows our custom control for editing the value.
/// </summary>
/// <param name="context">The context of the editing control</param>
/// <param name="provider">A valid service provider</param>
/// <param name="value">The current value of the object to edit</param>
/// <returns>The new value of the object</returns>
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if( context != null && context.Instance != null && provider != null )
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if( edSvc != null )
{
// Create a CheckedListBox and populate it with all the enum values
clb = new CheckedListBox();
clb.BorderStyle = BorderStyle.FixedSingle;
clb.CheckOnClick = true;
clb.MouseDown += new MouseEventHandler(this.OnMouseDown);
clb.MouseMove += new MouseEventHandler(this.OnMouseMoved);
clb.DoubleClick += new EventHandler( this.OnDoubleClick );
tooltipControl = new ToolTip();
tooltipControl.ShowAlways = true;
clb.BeginUpdate();
foreach( string name in Enum.GetNames( context.PropertyDescriptor.PropertyType ) )
{
// Get the enum value
object enumVal = Enum.Parse(context.PropertyDescriptor.PropertyType, name);
// Get the int value
int intVal = (int) Convert.ChangeType(enumVal, typeof(int));
// Get the description attribute for this field
System.Reflection.FieldInfo fi = context.PropertyDescriptor.PropertyType.GetField(name);
DescriptionAttribute[] attrs = ( DescriptionAttribute[] )
fi.GetCustomAttributes( typeof( DescriptionAttribute ), false );
BrowsableAttribute[] skipAttr = ( BrowsableAttribute[] )
fi.GetCustomAttributes( typeof( BrowsableAttribute ), false );
// if flag must be skip in desiner
if( skipAttr.Length > 0 && skipAttr[0].Browsable == false ) continue;
// Store the the description
string tooltip = ( attrs.Length > 0 ) ? attrs[0].Description : string.Empty;
// Get the int value of the current enum value (the one being edited)
int intEdited = ( int )Convert.ChangeType( value, typeof( int ) );
// show in tooltip int value of flag
tooltip += "(value: " + intEdited.ToString() + ")";
// Creates a clbItem that stores the name, the int value and the tooltip
clbItem item = new clbItem(enumVal.ToString(), intVal, tooltip);
// Get the checkstate from the value being edited
bool checkedItem = (intEdited & intVal) > 0;
// Add the item with the right check state
clb.Items.Add( item, checkedItem );
}
clb.EndUpdate();
// Show our CheckedListbox as a DropDownControl.
// This methods returns only when the dropdowncontrol is closed
edSvc.DropDownControl( clb );
// Get the sum of all checked flags
int result = 0;
foreach( clbItem obj in clb.CheckedItems )
{
result += obj.Value;
}
// return the right enum value corresponding to the result
return Enum.ToObject(context.PropertyDescriptor.PropertyType, result);
}
}
return value;
}
示例3: UpdateCheckedList
private void UpdateCheckedList(CheckedListBox list)
{
object wasSelected = list.SelectedItem;
list.BeginUpdate();
for (int i = 0; i < list.Items.Count; i++)
list.SetItemChecked(i, ((Item)list.Items[i]).IsVisible);
list.SelectedItem = wasSelected;
list.EndUpdate();
}
示例4: InitializeCheckedListBox
void InitializeCheckedListBox(CheckedListBox box, CheckableSelectableListNodeList list)
{
box.BeginUpdate();
box.Items.Clear();
for(int i=0;i<list.Count;i++)
{
CheckableSelectableListNode node=list[i];
box.Items.Add(node, node.Checked);
if (node.Selected)
box.SelectedIndices.Add(i);
}
box.EndUpdate();
}
示例5: FillOutDatabaseObjectNames
private void FillOutDatabaseObjectNames(string cmdName, CheckedListBox clb, DatabaseObjectType objectType)
{
string objectName;
string strCmd = ConfigurationManager.AppSettings[cmdName];
Database db = DatabaseFactory.CreateDatabase();
Action beginUpdate = () => clb.BeginUpdate();
clb.Invoke(beginUpdate);
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strCmd))
{
Action addItem;
while (reader.Read())
{
objectName = reader.GetString(0);
addItem = () => clb.Items.Add(new ListItem() { Value = objectName, Type = objectType });
clb.Invoke(addItem);
}
}
Action endUpdate = () => clb.EndUpdate();
clb.Invoke(endUpdate);
}
示例6: SetAllDatabaseObjectSelected
private void SetAllDatabaseObjectSelected(CheckedListBox dbObjectList, CheckBox chkAll)
{
dbObjectList.BeginUpdate();
for (int i = 0; i < dbObjectList.Items.Count; i++)
{
dbObjectList.SetItemChecked(i, chkAll.Checked);
}
dbObjectList.EndUpdate();
}