當前位置: 首頁>>代碼示例>>C#>>正文


C# ListBox.ClearSelected方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ListBox.ClearSelected方法的典型用法代碼示例。如果您正苦於以下問題:C# ListBox.ClearSelected方法的具體用法?C# ListBox.ClearSelected怎麽用?C# ListBox.ClearSelected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ListBox的用法示例。


在下文中一共展示了ListBox.ClearSelected方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Intercambiar

 public static bool Intercambiar(ListBox listaA, ListBox listaB, Stack destino, Stack origen)
 {
     Object item = listaB.SelectedItem;
     if (item.ToString() != origen.Peek().ToString())
     {
         MessageBox.Show("El elemnto no se puede mover", "Torres de Hanoi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         listaB.ClearSelected();
     }
     else{
         if (destino.Count == 0 || ((int)origen.Peek() < (int)destino.Peek()))
         {
             listaA.Items.Insert(0, item);
             listaB.Items.Remove(item);
             destino.Push(origen.Peek());
             origen.Pop();
             return true;
         }
     else
         {
             MessageBox.Show("Movimiento no valido", "Torres de Hanoi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             listaB.ClearSelected();
         }
     }
     return false;
 }
開發者ID:elein01,項目名稱:Aplicaciones,代碼行數:25,代碼來源:VistaHanoi.cs

示例2: SetObjectTimeSlots

 public static void SetObjectTimeSlots(ListBox listBoxRoom, IEnumerable<TimeSlot> timeSlots)
 {
     listBoxRoom.ClearSelected();
     foreach (var timeSlot in timeSlots)
     {
         for (uint i = timeSlot.StartHour; i < timeSlot.EndHour; i++)
         {
             listBoxRoom.SetSelected((int)i - 7, true);
         }
     }
 }
開發者ID:victoria92,項目名稱:university-program-generator,代碼行數:11,代碼來源:UIHelpers.cs

示例3: RefreshForm

        /// <summary>
        /// Refreshes the list box items for the resolutions tab
        /// </summary>
        /// <param name="removeSelected">Removes the selected item</param>
        public void RefreshForm(ListBox listBox, bool removeSelected)
        {
            if (removeSelected)
            {
                object o = listBox.SelectedItem.ToString();

                // Remove the current selected item
                listBox.Items.Remove(o);

                // Remove the auto change item
                listBox.Items.Remove(o);
            }

            // Clear the selected items
            listBox.ClearSelected();
        }
開發者ID:StevenFrost,項目名稱:Editors,代碼行數:20,代碼來源:OptionsResolutionList.cs

示例4: CreateList

 private void CreateList(object newCard, object cardList, CardType cardType)
 {
     if (cardType == CardType.CHARACTER)
     {
         var cards = (List<CharacterCard>)cardList;
         cards.Add((CharacterCard)newCard);
         lstPlayerCards.DataSource = cards;
     }
     else
     {
         var cards = (List<EventCard>)cardList;
         cards.Add((EventCard)newCard);
         lstPlayerCards.DataSource = cards;
         _characterBox = new ListBox();
         Width = Width + 110;
         _characterBox.Location = new Point(280, 12);
         _characterBox.Height = lstPlayerCards.Height;
         _characterBox.Width = 100;
         this.Controls.Add(_characterBox);
         _characterBox.DataSource = ((EventCard)lstPlayerCards.SelectedItem).Characters;
         _characterBox.ClearSelected();
     }
 }
開發者ID:andycornforth,項目名稱:Lost_Card_Game,代碼行數:23,代碼來源:SwapCardForm.cs

示例5: CreateMulti

        public static Control CreateMulti(Indicator indicator, string val, ErrorProvider indicatorErrors, List<DynamicContainer> controlList,
            IndicatorEntityType entityType, List<IndicatorDropdownValue> dropdownKeys)
        {
            List<IndicatorDropdownValue> availableValues = new List<IndicatorDropdownValue>();
            var container = new DynamicContainer { Indicator = indicator };
            var cntrl = new ListBox { Name = "dynamicMulti" + indicator.Id.ToString(), Width = 220, Height = 100, Margin = new Padding(0, 5, 20, bottomPadding), SelectionMode = SelectionMode.MultiExtended };

            // Add the Control to the DynamicContainer for reference
            container.Control = cntrl;
            
            foreach (var v in dropdownKeys.Where(k => k.IndicatorId == indicator.Id).OrderBy(i => i.SortOrder))
            {
                cntrl.Items.Add(v);
                availableValues.Add(v);
            }
            cntrl.ValueMember = "Id";
            cntrl.DisplayMember = "DisplayName";
            if (!string.IsNullOrEmpty(val))
            {
                string[] vals = val.Split('|');
                cntrl.ClearSelected();
                foreach (var av in availableValues.Where(v => vals.Contains(v.TranslationKey)))
                    cntrl.SelectedItems.Add(av);
            }

            container.GetValue = () =>
            {
                List<string> selected = new List<string>();
                foreach (var i in cntrl.SelectedItems)
                    selected.Add((i as IndicatorDropdownValue).TranslationKey);
                return string.Join("|", selected.ToArray());
            };

            container.IsValid = () =>
            {
                if (indicator.IsRequired && indicatorErrors != null)
                {
                    if (string.IsNullOrEmpty(container.GetValue()))
                    {
                        indicatorErrors.SetError(cntrl, Translations.Required);
                        return false;
                    }
                    else
                        indicatorErrors.SetError(cntrl, "");
                }
                return true;
            };
            cntrl.Validating += (s, e) => { container.IsValid(); };

            controlList.Add(container);

            if (indicator.CanAddValues)
                return AddNewValLink(cntrl, indicator, entityType);
            else
                return cntrl;
        }
開發者ID:ericjohnolson,項目名稱:NadaNtd,代碼行數:56,代碼來源:ControlFactory.cs

示例6: SearchAllv5

        public void SearchAllv5(string searchString, ListBox box, string searchType)
        {
            box.Invoke(new Action(() => box.ClearSelected()));
            string pattern = Regex.Escape(searchString).ToLower();

            if (searchString != string.Empty)
            {
                List<string> list = new List<string>();

                // KFreon: Hash search
                if (searchString.Length > 2 && searchString.Substring(0, 2) == "0x")
                {
                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        string thing = searchString.Substring(2).ToLowerInvariant();
                        string fromGame = KFreonLib.Textures.Methods.FormatTexmodHashAsString(tex.Hash).Substring(2).ToLowerInvariant();
                        if (fromGame.Contains(thing))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else if (searchString[0] == '@')   // KFreon: Export ID search
                {
                    int expID = 0;
                    if (!int.TryParse(searchString.Substring(1), out expID))
                        return;

                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        if (tex.ExpIDs.Contains(expID))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else if (searchString[0] == '\\')  // KFreon: Filename search
                {
                    int exppos = searchString.IndexOf('@');
                    int length = searchString.Length - (searchString.Length - exppos) - 2;
                    string name = (exppos == -1) ? searchString.Substring(1).ToLowerInvariant() : searchString.Substring(1, length).ToLowerInvariant();


                    if (exppos != -1)  // KFreon: Filename + ExpID search
                    {
                        int expID = 0;
                        if (!int.TryParse(searchString.Substring(exppos + 1), out expID))
                            return;

                        for (int i = 0; i < texes.Count; i++)
                        {
                            TreeTexInfo tex = texes[i];
                            for (int j = 0; j < tex.Files.Count; j++)
                                if (tex.Files[j].Split('\\').Last().ToLowerInvariant().Contains(name) && tex.ExpIDs[j] == expID)
                                    list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                        }
                    }
                    else  // KFreon: Normal filename search
                        for (int i = 0; i < texes.Count; i++)
                        {
                            TreeTexInfo tex = texes[i];
                            foreach (string filename in tex.Files)
                                if (filename.Split('\\').Last().ToLowerInvariant().Contains(name))
                                    list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                        }
                }
                else if (searchString[0] == '-')  // KFreon: Thumbnail search
                {
                    string searchstr = searchString.Substring(1).ToLowerInvariant();
                    foreach (TreeTexInfo tex in texes)
                    {
                        string name = Path.GetFileNameWithoutExtension(tex.ThumbnailPath).ToLowerInvariant();
                        if (name.Contains(searchstr))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else  // KFreon: Normal search
                {
                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        string name = tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")";
                        string s = name.ToLower();
                        Match match = Regex.Match(s, pattern, RegexOptions.IgnoreCase);
                        if (match.Success)
                            list.Add(s);
                    }
                }
                box.Invoke(new Action(() =>
                {
                    box.Items.Clear();
                    box.Items.AddRange(list.ToArray());
                }));
            }
        }
開發者ID:CreeperLava,項目名稱:ME3Explorer,代碼行數:93,代碼來源:KFreonSearchForm.cs

示例7: PopulateSPSites

        private void PopulateSPSites(Guid guidWebApp, ListBox listBoxSPSite)
        {
            //if (dictSPSite.Count > 0)
            //    dictSPSite.Clear();
            if (listBoxSPSite.Items.Count > 0)
                listBoxSPSite.Items.Clear();

            SPWebApplication objSPWebApp = SPWebService.ContentService.WebApplications[guidWebApp];
            foreach (SPSite objSPSite in objSPWebApp.Sites)
            {
                if (objSPSite.Url.EndsWith(@"Office_Viewing_Service_Cache"))
                    continue;

                //dictSPSite.Add(objSPSite.Url, string.Format("{0}, {1}", objSPSite.RootWeb.Title, objSPSite.Url));
                listBoxSPSite.Items.Add(new KeyValuePair<string, string>(objSPSite.Url, string.Format("{0}, {1}", objSPSite.RootWeb.Title, objSPSite.Url)));
            }

            //listBoxSPSite.DataSource = new BindingSource(dictSPSite, null);
            listBoxSPSite.DisplayMember = "Value";
            listBoxSPSite.ValueMember = "Key";

            listBoxSPSite.ClearSelected();

            textBoxPSScript.Text = string.Empty;
            _dictPSScriptBackup.Clear();
        }
開發者ID:Eric-Fang,項目名稱:SPSiteAdmin2010,代碼行數:26,代碼來源:Form1.cs

示例8: HighlightPayDate

 public void HighlightPayDate(ListBox lb)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     lb.ClearSelected();
     decimal totalDiv = 0;
     decimal quarterlyDiv = 0;
     int cnt = 0;
     string monthYear = "";
     string dtpMonthYear = "";
     string individualDivData = "";
     DataTable dt = DividendStocks.GetCurrentDividends();
     for (int i = 0; i < lb.Items.Count; i++)
     {
         DataRowView drv = lb.Items[i] as DataRowView;
         string[] date = drv["symbolName"].ToString().Split('*');
         string[] symbolSplit = date[0].Split('-');
         string symbol = symbolSplit[0].Trim();
         if (date.Length == 2)
         {
             monthYear = date[1].ToString();
             if (monthYear != "N/A")
             {
                 date = monthYear.Split('/');
                 monthYear = date[0].Trim() + "/" + date[2];
                 dtpMonthYear = dtpPayDate.Value.ToString("MM/yyyy");
                 //string dividendInterval = GetDividendInterval(Convert.ToInt32(drv["id"]), dt);
                 //if (dividendInterval == "Monthly")
                 //{
                 //    lb.SelectedIndices.Add(i);
                 //    totalDiv += GetDiv(Convert.ToInt32(drv["id"]), dt);
                 //    individualDivData += symbol + ": $" + Math.Round((GetDiv(Convert.ToInt32(drv["id"]), dt) / 4), 2) + "\n\n";
                 //}
                 if (monthYear == dtpMonthYear)
                 {
                     lb.SelectedIndices.Add(i);
                     totalDiv += GetDiv(Convert.ToInt32(drv["id"]), dt);
                     individualDivData += symbol + ": $" + Math.Round((GetDiv(Convert.ToInt32(drv["id"]), dt) / 4), 2) + "\n\n";
                     cnt++;
                 }
             }
         }
     }
     HighlightActive = false;
     quarterlyDiv = totalDiv / 4;
     pw.Close();
     if (cnt != 0)
     {
         MessageBox.Show(string.Format("{0} results\n\n" + "{1} \n\n" + individualDivData + "Total: ${2}\n\n", cnt, "Dividends for " + dtpMonthYear + ":",  Math.Round(quarterlyDiv, 2)));
     }
     else
     {
         MessageBox.Show(string.Format("No Results for {0}", dtpMonthYear));
     }
 }
開發者ID:eplugplay,項目名稱:DividendLibertyPersonal,代碼行數:56,代碼來源:MainMenu.cs

示例9: Add

        /// <summary>
        /// Add the selected items from the specified source <c>ListBox</c> control to the specified destination <c>ListBox</c> control.
        /// </summary>
        /// <param name="listSource">The source <c>ListBox</c> control.</param>
        /// <param name="listDestination">the destination <c>ListBox</c> control.</param>
        protected override void Add(ref ListBox listSource, ref ListBox listDestination)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            int count = listSource.SelectedItems.Count;
            int currentIndex = listSource.SelectedIndex;

            // Skip, if no items have been selected.
            if (count == 0)
            {
                return;
            }

            if ((m_ListItemCount + count) > Parameter.SizeTestList)
            {
                MessageBox.Show(Resources.MBTSelfTestsMaxExceeded, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Cursor = Cursors.WaitCursor;

            // ---------------------------------------------------------------------------------------
            // For each selected item: (a) add this to the destination list and update the added flag.
            // ---------------------------------------------------------------------------------------
            int selfTestIdentifier;
            for (int index = 0; index < count; ++index)
            {
                // Add the item to the destination list.
                listDestination.Items.Add(listSource.SelectedItems[index]);

                // Keep track of the number of tests that have been added to the test list.
                m_ListItemCount++;

                selfTestIdentifier = ((TestItem_t)listSource.SelectedItems[index]).SelfTestIdentifier;

                // Keep track of which watch variables have been removed.
                m_TestItems[selfTestIdentifier].Added = true;

                AddSupplementalFields(selfTestIdentifier);
            }

            UpdateCount();

            // Highlight the next item for processing if the list is not empty.
            if (listSource.Items.Count > 0)
            {
                // Bounds checking.
                if (currentIndex < listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex;
                }
                else if (currentIndex == listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex - 1;
                }
            }

            // Scroll to the end of the list.
            listDestination.SetSelected(listDestination.Items.Count - 1, true);
            listDestination.ClearSelected();

            m_ButtonApply.Enabled = true;
            OnDataUpdate(this, new EventArgs());
            Cursor = Cursors.Default;
        }
開發者ID:SiGenixDave,項目名稱:PtuPCNew,代碼行數:74,代碼來源:FormTestListDefine.cs

示例10: ShowMessage

 private void ShowMessage(ListBox listbox, string text)
 {
     if (listbox.InvokeRequired)
     {
         ShowMessageCallBack showmessageCallback = ShowMessage;
         listbox.Invoke(showmessageCallback, new object[] { listbox, text });
     }
     else
     {
         listbox.Items.Add(text);
         listbox.SelectedIndex = listbox.Items.Count - 1;
         listbox.ClearSelected();
     }
 }
開發者ID:svn2github,項目名稱:eztx,代碼行數:14,代碼來源:Form1.cs

示例11: Add

        /// <summary>
        /// Add the selected items from the specified source <c>ListBox</c> control to the specified destination <c>ListBox</c> control.
        /// </summary>
        /// <param name="listSource">The source <c>ListBox</c> control.</param>
        /// <param name="listDestination">the destination <c>ListBox</c> control.</param>
        protected override void Add(ref ListBox listSource, ref ListBox listDestination)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            int count = listSource.SelectedItems.Count;
            int currentIndex = listSource.SelectedIndex;

            // Skip, if no items have been selected.
            if (count == 0)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // ------------------------------------------------------------------------------------------------------------------------------
            // For each selected item: (a) add this to the destination list; (b) delete from the source list and (c) update the removed flag.
            // ------------------------------------------------------------------------------------------------------------------------------
            int oldIdentifier;
            for (int index = 0; index < count; ++index)
            {
                // Add the item to the destination list.
                listDestination.Items.Add(listSource.SelectedItems[index]);

                // Keep track of the number of watch elements that have been added to the workset.
                m_ListItemCount++;

                oldIdentifier = ((WatchItem_t)listSource.SelectedItems[index]).OldIdentifier;

                // Keep track of which watch variables have been removed.
                m_WatchItems[oldIdentifier].Added = true;

                AddSupplementalFields(oldIdentifier);
            }

            UpdateCount();

            // Highlight the next item for processing if the list is not empty.
            if (listSource.Items.Count > 0)
            {
                // Bounds checking.
                if (currentIndex < listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex;
                }
                else if (currentIndex == listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex - 1;
                }
            }

            // Scroll to the end of the list.
            listDestination.SetSelected(listDestination.Items.Count - 1, true);
            listDestination.ClearSelected();

            EnableApplyAndOKButtons();
            OnDataUpdate(this, new EventArgs());
            Cursor = Cursors.Default;
        }
開發者ID:SiGenixDave,項目名稱:PtuPCNew,代碼行數:68,代碼來源:FormPlotDefine.cs

示例12: PopulateTracks

        /* add songs depending on album(s) selected */
        public void PopulateTracks(ListBox lb, string artist, string album)
        {
            lb.Items.Clear();
            lb.ClearSelected();
            XmlTrackList = GetTracks(artist, album);

            foreach (XElement el in XmlTrackList)
            {
                if(el.Element("Title").Value != null)
                    lb.Items.Add(el.Element("Title").Value);
            }
        }
開發者ID:nickbean01,項目名稱:MusicPlaya,代碼行數:13,代碼來源:MusicLibrary.cs

示例13: Add

        /// <summary>
        /// Add the selected items from the specified source <c>ListBox</c> control to the specified destination <c>ListBox</c> control.
        /// </summary>
        /// <param name="listSource">The source <c>ListBox</c> control.</param>
        /// <param name="listDestination">the destination <c>ListBox</c> control.</param>
        protected virtual void Add(ref ListBox listSource, ref ListBox listDestination)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            int count = listSource.SelectedItems.Count;
            int currentIndex = listSource.SelectedIndex;

            // Skip, if no items have been selected.
            if (count == 0)
            {
                return;
            }

			if ((m_ListItemCount + count) > EntryCountMax)
            {
                MessageBox.Show(Resources.MBTWorksetDefineMaxExceeded, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Cursor = Cursors.WaitCursor;

            // ------------------------------------------------------------------------------------------------------------------------------
            // For each selected item: (a) add this to the destination list; (b) delete from the source list and (c) update the added flag.
            // ------------------------------------------------------------------------------------------------------------------------------
            int oldIdentifier;
            for (int index = 0; index < count; ++index)
            {
                // Add the item to the destination list.
                listDestination.Items.Add(listSource.SelectedItems[index]);

                // Keep track of the number of watch elements that have been added to the workset.
                m_ListItemCount++;

                oldIdentifier = ((WatchItem_t)listSource.SelectedItems[index]).OldIdentifier;

                // Keep track of which watch variables have been removed.
                m_WatchItems[oldIdentifier].Added = true;

                AddSupplementalFields(oldIdentifier);
            }

            // Remember the selected item list contents will change every time an item is deleted. The best approach is to repeatedly remove the selected items
            // collection for index = 0 by the number of items added to the destination list.
            for (int index = 0; index < count; ++index)
            {
                // Keep track of these changes in case the user selects the cancel key.
				m_AddedWatchVariables.Add(listSource.SelectedItems[0]);

                listSource.Items.Remove(listSource.SelectedItems[0]);
            }

            UpdateCount();

            // Highlight the next item for processing if the list is not empty.
            if (listSource.Items.Count > 0)
            {
                // Bounds checking.
                if (currentIndex < listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex;
                }
                else if (currentIndex == listSource.Items.Count)
                {
                    listSource.SelectedIndex = currentIndex - 1;
                }
            }

            // Scroll to the end of the list.
            listDestination.SetSelected(listDestination.Items.Count - 1, true);
            listDestination.ClearSelected();

            EnableApplyAndOKButtons();
            OnDataUpdate(this, new EventArgs());
            Cursor = Cursors.Default;
        }
開發者ID:SiGenixDave,項目名稱:PtuPCNew,代碼行數:84,代碼來源:FormWorksetDefine.cs

示例14: UpdateListBoxItem

 private void UpdateListBoxItem(ListBox lb, object item)
 {
     int index = lb.Items.IndexOf(item);
     int currentIndex = lb.SelectedIndex;
     lb.BeginUpdate();
     try
     {
         lb.ClearSelected();
         lb.Items[index] = item;
         lb.SelectedIndex = currentIndex;
     }
     finally
     {
         lb.EndUpdate();
     }
 }
開發者ID:BioRoboticsUNAM,項目名稱:Blackboard,代碼行數:16,代碼來源:Form1.cs

示例15: CreatePartners

        public static Control CreatePartners(Indicator indicator, string val, ErrorProvider indicatorErrors, List<DynamicContainer> controlList)
        {
            var container = new DynamicContainer { Indicator = indicator };
            var cntrl = new ListBox { Name = "dynamicPartners" + indicator.Id.ToString(), Width = 220, Height = 100, Margin = new Padding(0, 5, 20, bottomPadding), SelectionMode = SelectionMode.MultiExtended };

            List<Partner> partners = GetAndLoadPartners(cntrl);
            cntrl.ValueMember = "Id";
            cntrl.DisplayMember = "DisplayName";
            if (!string.IsNullOrEmpty(val))
            {
                string[] vals = val.Split('|');
                cntrl.ClearSelected();
                foreach (var av in partners.Where(v => vals.Contains(v.Id.ToString())))
                    cntrl.SelectedItems.Add(av);
            }

            container.GetValue = () =>
            {
                List<string> selected = new List<string>();
                foreach (var i in cntrl.SelectedItems)
                    selected.Add((i as Partner).Id.ToString());
                return string.Join("|", selected.ToArray());
            };

            container.IsValid = () =>
            {
                if (indicator.IsRequired && indicatorErrors != null)
                {
                    if (string.IsNullOrEmpty(container.GetValue()))
                    {
                        indicatorErrors.SetError(cntrl, Translations.Required);
                        return false;
                    }
                    else
                        indicatorErrors.SetError(cntrl, "");
                }
                return true;
            };
            cntrl.Validating += (s, e) => { container.IsValid(); };

            // Add table container and link
            controlList.Add(container);
            cntrl.Margin = new Padding(0, 5, 20, 0);
            TableLayoutPanel tblContainer = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, AutoScroll = true };
            tblContainer.RowStyles.Clear();
            tblContainer.ColumnStyles.Clear();
            int cRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            tblContainer.Controls.Add(cntrl, 0, cRow);
            int lRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            var lnk = new H3Link { Text = Translations.AddNewItemLink, Margin = new Padding(0, 0, 3, bottomPadding) };
            lnk.ClickOverride += () =>
            {
                PartnerList list = new PartnerList();
                list.OnSave += () =>
                {
                    partners = GetAndLoadPartners(cntrl);
                };
                list.ShowDialog();
            };
            tblContainer.Controls.Add(lnk, 0, lRow);

            return tblContainer;
        }
開發者ID:ericjohnolson,項目名稱:NadaNtd,代碼行數:63,代碼來源:ControlFactory.cs


注:本文中的System.Windows.Forms.ListBox.ClearSelected方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。