当前位置: 首页>>代码示例>>C#>>正文


C# ListBox.BeginUpdate方法代码示例

本文整理汇总了C#中System.Windows.Forms.ListBox.BeginUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.BeginUpdate方法的具体用法?C# ListBox.BeginUpdate怎么用?C# ListBox.BeginUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ListBox的用法示例。


在下文中一共展示了ListBox.BeginUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChemtoolsGui

        private ChemtoolsGui()
        {
            this.Text = "ChemTools";
            this.Size = new Size(640, 640);

            input = new TextBox();
            input.Location = new Point(20, 20);
            input.Size = new Size(250, 20);
            input.TextChanged += new EventHandler(InputChanged);
            input.KeyDown += new KeyEventHandler(InputKeyDown);

            output = new RichTextBox();
            output.Location = new Point(50, 160);
            output.Size = new Size(250, 300);

            savedList = new ListBox();
            savedList.Location = new Point(300, 20);
            savedList.Size = new Size(300, 120);
            savedList.SelectedIndexChanged += new EventHandler(ListSelectChange);
            savedList.KeyDown += new KeyEventHandler(ListKeyDown);
            savedList.BeginUpdate();
            savedList.Items.Add("H2O");
            savedList.Items.Add("CO2");
            savedList.Items.Add("C4H10+O2=CO2+H2O");
            savedList.Items.Add("44.0095gCO2");
            savedList.EndUpdate();

            savedOutput = new RichTextBox();
            savedOutput.Location = new Point(300, 160);
            savedOutput.Size = new Size(250, 300);

            btnAdd = new Button();
            btnAdd.Location = new Point(180, 50);
            btnAdd.Text = "Save";
            btnAdd.Click += new EventHandler(AddClick);

            btnDelete = new Button();
            btnDelete.Location = new Point(180, 100);
            btnDelete.Text = "Delete";
            btnDelete.Click += new EventHandler(DeleteClick);

            btnClear = new Button();
            btnClear.Location = new Point(20, 50);
            btnClear.Text = "Clear";
            btnClear.Click += new EventHandler(ClearClick);

            btnReset = new Button();
            btnReset.Location = new Point(20, 100);
            btnReset.Text = "Reset All";
            btnReset.Click += new EventHandler(ResetClick);

            this.Controls.Add(input);
            this.Controls.Add(output);
            this.Controls.Add(savedList);
            this.Controls.Add(savedOutput);
            this.Controls.Add(btnAdd);
            this.Controls.Add(btnDelete);
            this.Controls.Add(btnClear);
            this.Controls.Add(btnReset);
        }
开发者ID:tcooc,项目名称:ChemtoolsCs,代码行数:60,代码来源:ChemtoolsGui.cs

示例2: CompareLists

        /// <summary>
        /// Compares the lists of articles in the 2 provided Lists
        /// Best to provide an already sorted list. List 1 should be the smallest list
        /// </summary>
        /// <param name="list1">First List (preferably the smallest)</param>
        /// <param name="list2">Second List</param>
        /// <param name="lb1">List Box where unique items from list1 should go</param>
        /// <param name="lb2">List Box where unique items from list2 should go</param>
        /// <param name="lb3">List Box where the duplicates should go</param>
        private static void CompareLists(IList<Article> list1, ICollection<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            while (list1.Count > 0)
            {
                Article a = list1[0];
                if (list2.Contains(a))
                {
                    lb3.Items.Add(a.Name);
                    list2.Remove(a);
                }
                else
                    lb1.Items.Add(a.Name);

                list1.Remove(a);
            }

            foreach (Article article in list2)
            {
                lb2.Items.Add(article.Name);
            }

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:38,代码来源:ListComparer.cs

示例3: ReadFile

        public static int ReadFile(string fileName, ListBox listbox)
        {
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open)))
                {
                    listbox.BeginUpdate();

                    while (!sr.EndOfStream)
                    {
                        string str = sr.ReadLine();

                        if(str.Length > 0)
                            listbox.Items.Add(str);
                    }

                    listbox.EndUpdate();

                    sr.Close();

                    return 0;
                }
            }

            return -1;
        }
开发者ID:NeuroWhAI,项目名称:WhenFullScreen,代码行数:26,代码来源:ListboxDataFile.cs

示例4: OnEdit

 /// <summary>
 /// ¬озвращает измененное значение свойства
 /// </summary>
 /// <param name="value">»сходное значение</param>
 protected override Object OnEdit(Object value)
 {
     // создаем выпадающий список значений
     ListBox valuesList = new ListBox();
     valuesList.BorderStyle = BorderStyle.None;
     valuesList.BeginUpdate();
     try
     {
         // заполн¤ем список значени¤ми
         valuesList.Items.AddRange(Values);
     }
     finally
     {
         valuesList.EndUpdate();
     }
     // определ¤ем высоту списка
     Int32 heightMultiplier = valuesList.Items.Count > 7 ? 7 : valuesList.Items.Count;
     valuesList.Height = valuesList.ItemHeight * (heightMultiplier + 1);
     // выбираем строку в списке в зависимости от значени¤ свойства
     valuesList.SelectedIndex = ObjectToIndex(value);
     // добавл¤ем поддержку закрыти¤ по щелчку мыши
     valuesList.Click += new EventHandler(valuesList_Click);
     // открываем список значений
     EdSvc.DropDownControl(valuesList);
     // возвращаем выбранное значение свойства
     return IndexToObject(valuesList.SelectedIndex);
 }
开发者ID:Dennis-Petrov,项目名称:Cash,代码行数:31,代码来源:CustomDropdownEditor.cs

示例5: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            // Create an instance of the ListBox.
            ListBox listBox1 = new ListBox();
            // Set the size and location of the ListBox.
            listBox1.Size = new System.Drawing.Size(200, 100);
            listBox1.Location = new System.Drawing.Point(10, 10);
            // Add the ListBox to the form.
            this.Controls.Add(listBox1);
            // Set the ListBox to display items in multiple columns.
            listBox1.MultiColumn = true;
            // Set the selection mode to multiple and extended.
            listBox1.SelectionMode = SelectionMode.MultiExtended;

            // Shutdown the painting of the ListBox as items are added.
            listBox1.BeginUpdate();
            // Loop through and add 50 items to the ListBox.
            for (int x = 1; x <= 50; x++)
            {
                listBox1.Items.Add("Item " + x.ToString());
            }
            // Allow the ListBox to repaint and display the new items.
            listBox1.EndUpdate();

            // Select three items from the ListBox.
            listBox1.SetSelected(1, true);
            listBox1.SetSelected(3, true);
            listBox1.SetSelected(5, true);

            // Display the second selected item in the ListBox to the console.
            System.Diagnostics.Debug.WriteLine(listBox1.SelectedItems[1].ToString());
            // Display the index of the first selected item in the ListBox.
            System.Diagnostics.Debug.WriteLine(listBox1.SelectedIndices[0].ToString());
        }
开发者ID:klimskuridin,项目名称:vamk_csharp,代码行数:34,代码来源:Form1.cs

示例6: FillListBox

 public static int FillListBox(ListBox lb, List<string> list)
 {
     lb.BeginUpdate();
     foreach(var s in list)
     lb.Items.Add(s);
     lb.EndUpdate();
     return lb.Items.Count;
 }
开发者ID:emm274,项目名称:fcObj,代码行数:8,代码来源:xedits.cs

示例7: Populate

 /// <summary>
 /// Clears and fills the control with the given data. 
 /// </summary>
 /// <param name="ctrl">Listbox 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(ListBox 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();
 }
开发者ID:borisblizzard,项目名称:arcreator,代码行数:17,代码来源:ControlHelper.cs

示例8: SetListItems

        public static void SetListItems(ListBox listBox, ListItemWithId[] items)
        {
            listBox.Text = "";
            listBox.Items.Clear();

            listBox.BeginUpdate();

            for (int i = 0; i < items.Length; i++)
                listBox.Items.Add(items[i]);

            listBox.EndUpdate();
        }
开发者ID:gitfunk,项目名称:7thSea,代码行数:12,代码来源:SeventhSeaUtils.cs

示例9: ShowInfoProc

        private void ShowInfoProc(string strMsg, ListBox lstBox, int nMax)
        {
            lstBox.BeginInvoke((Action)delegate ()
            {
                lstBox.BeginUpdate();
                lstBox.Items.Add(strMsg);
                if (nMax > 0)
                {
                    while (lstBox.Items.Count > nMax)
                        lstBox.Items.RemoveAt(0);
                }

                // Scroll to end
                //
                lstBox.SelectedIndex = lstBox.Items.Count - 1;
                lstBox.EndUpdate();
            });
        }        
开发者ID:s850042002,项目名称:ostock-simulation,代码行数:18,代码来源:Form1.cs

示例10: MoveComponent

        private void MoveComponent(ListBox source, ListBox dest, IEnumerable<DeckManager.Components.BaseComponent> items)
        {
            source.BeginUpdate();
            dest.BeginUpdate();

            source.Items.Remove(items);
            dest.Items.AddRange(items.ToArray());

            // probably a better way to get the nodenames but whatever
            DeckManager.Boards.Dradis.DradisNodeName SourceNode;
            _sectors.TryGetValue(source, out SourceNode);
            DeckManager.Boards.Dradis.DradisNodeName DestNode;
            _sectors.TryGetValue(dest, out DestNode);
            Program.GManager.MoveComponents(SourceNode, DestNode, items);

            source.EndUpdate();
            dest.EndUpdate();
            // todo add rollback on error checking?
        }
开发者ID:MaxPeck,项目名称:DeckManager,代码行数:19,代码来源:DradisForm.cs

示例11: EditValue

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            ListBox listBox = new ListBox();
            listBox.SelectionMode = SelectionMode.One;
            listBox.SelectedValueChanged += OnListBoxSelectedValueChanged;
            listBox.DisplayMember = nameof(AbstractSkin.Name);
            listBox.BeginUpdate();
            foreach (var skinType in WinFwkHelper.GetDerivedTypes(typeof(AbstractSkin)))
            {
                var skin = Activator.CreateInstance(skinType);
                listBox.Items.Add(skin);
            }
            listBox.EndUpdate();
            listBox.Sorted = true;
            editorService.DropDownControl(listBox);
            if (listBox.SelectedItem == null) // no selection, return the passed-in value as is
                return value;

            return listBox.SelectedItem;
        }
开发者ID:fremag,项目名称:MemoScope.Net,代码行数:22,代码来源:SkinTypeEditor.cs

示例12: NewDecisionListBox

        public ListBox NewDecisionListBox(List<DecisionTree> dtChildren)
        {
            ListBox retVal = new ListBox();
            retVal.Font = new Font("Courier New", 8);
            retVal.ScrollAlwaysVisible = true;
            retVal.Width = 223;
            retVal.BeginUpdate();

            foreach (DecisionTree curDecision in dtChildren)
            {
                if (curDecision.Move != null)
                {
                    if ((curDecision.Parent != null) &&
                        (curDecision.Parent.BestChildMove != null) &&
                        (curDecision.Parent.BestChildMove == curDecision.Move))
                    {
                        curDecision.Move.ToStringPrefix = "-> ";
                    }
                    else
                    {
                        curDecision.Move.ToStringPrefix = "   ";
                    }
                }
                else
                {
                    retVal.Width = 140;
                }

                retVal.Items.Add(curDecision);
            }

            retVal.EndUpdate();

            retVal.Height = this.splitContainer1.Panel2.Height - this.hScrollBar1.Height;
            retVal.SelectedIndexChanged += this.OnSelectedIndexChanged;

            return retVal;
        }
开发者ID:ErichDonGubler,项目名称:uvschess,代码行数:38,代码来源:GuiDecisionTree.cs

示例13: populateListBox

		private void populateListBox(ListBox listBox, int maxID, string listName) {
			List<String> strings = LanguageManager.GetList(listName);

			listBox.BeginUpdate();
			listBox.Items.Clear();
			for (int i = 0; i < maxID; i++)
				listBox.Items.Add(string.Format(LanguageManager.Get("BehaviorEditor", "unknown"), i));

			foreach (string item in strings) {
				int where = item.IndexOf('=');

				int idx;
				if (item.StartsWith("0x"))
					idx = int.Parse(item.Substring(2, where-2), System.Globalization.NumberStyles.AllowHexSpecifier);
				else
					idx = int.Parse(item.Substring(0, where));

				string text = item.Substring(where+1);

				listBox.Items[idx] = text;
			}
			listBox.EndUpdate();
		}
开发者ID:elfinlazz,项目名称:NSMB-Editor,代码行数:23,代码来源:BehaviorEditor.cs

示例14: UpdateList

		public static void UpdateList(ListBox listView, SelectableListNodeList items)
		{
			listView.SelectedIndexChanged -= EhListBoxSelectedIndexChanged;
			listView.BeginUpdate();
			listView.Items.Clear();
			for (int i = 0; i < items.Count; i++)
			{
				listView.Items.Add(items[i]);
				if (items[i].Selected)
					listView.SelectedIndex = i;
			}

			listView.EndUpdate();
			listView.SelectedIndexChanged += EhListBoxSelectedIndexChanged;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:15,代码来源:GuiHelper.cs

示例15: AddLog2List

 public static void AddLog2List(ListBox lstAct, string content)
 {
     try
     {
         if (lstAct.InvokeRequired)
         {
             lstAct.Invoke(new AddLog(AddLog2List), new object[] { lstAct, content });
         }
         else
         {
             lstAct.BeginUpdate();
             lstAct.Items.Add(content);
             lstAct.EndUpdate();
         }
     }
     catch
     {
     }
 }
开发者ID:khaha2210,项目名称:radio,代码行数:19,代码来源:CommonLibrary.cs


注:本文中的System.Windows.Forms.ListBox.BeginUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。