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


C# ListBox.SelectAll方法代码示例

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


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

示例1: addAllItems

        public void addAllItems(ListBox src, ListBox target, bool IsReset = false)
        {
            try
            {
                if (src == null || target == null) return;

                if (IsReset == true)
                {
                    target.Items.Clear();
                }

                src.UnselectAll();
                src.SelectAll();
                addItems(src, target);

                if (IsReset == true)
                {
                    src.UnselectAll();
                    target.UnselectAll();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:26,代码来源:BoxExchangeEditor.cs

示例2: import_leads

        public void import_leads()
        {
            try
            {
                //FileStream Filewriter = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"import_lead.xml", FileMode.OpenOrCreate);
                //System.Xml.XmlDocument mydoc = new System.Xml.XmlDocument();
                //mydoc.lo

                //making xml file
                
                if (lstLists.SelectedIndex == -1)
                {
                    MessageBox.Show("Select from List");
                }
                //else if (lstFilterType.SelectedIndex == -1)
                //{
                //    MessageBox.Show("Select Filter Type");
                //}
                else                 
                {
                    string xmlFileData = "<Root>";
                    //1)cmbFormat array of string 
                    string[] str = ((ListBoxItem)cmbFormat.SelectedItem).Tag.ToString().Split(',');

                    xmlFileData += "<cmbFormat>";
                    //
                    for (int i = 0; i < str.Length; i++)
                    {
                        //xmlFileData += "<item" + i + " value=" + str[i] + "\"></item" + i + ">";
                        xmlFileData += "<Item value='" + str[i] + "'></Item>";
                        //Filewriter.Write("");
                    }
                    xmlFileData += "</cmbFormat>";

                    //2)cmbListType
                    string cmbListValue = cmbListType.SelectionBoxItem.ToString();
                    string cmbListKey = cmbListType.SelectedIndex.ToString();
                    xmlFileData += "<cmbListType>";
                    xmlFileData += "<item1 key=\"" + cmbListKey + "\" value=\"" + cmbListValue + "\"></item1>";
                    xmlFileData += "</cmbListType>";

                    //3)lstLists SelectedItem
                    //(ListBoxItem)lstLists.SelectedItem).Tag
                    //lstLists.SelectedItems (list of all 

                    xmlFileData += "<lstLists>";

                    string lstListkey = ((ListBoxItem)lstLists.SelectedItem).ToString();
                    string lstListvalue = ((ListBoxItem)lstLists.SelectedItem).Tag.ToString();
                    xmlFileData += "<Item1 key=\"" + lstListkey + "\" value=\"" + lstListvalue + "\"></Item1>";
                    xmlFileData += "</lstLists>";

                    //4)lstFilterType
                    //all selected items and tags
                    //selectedIndex
                    //string[] strFilterValues = ((ListBoxItem)lstFilterType.SelectedItems[cntFilter]).Tag.ToString().Split(',');
                    //selectedItems.count
                    //Getting all condition of a filter

                    #region Getting all condition of a filter
                    if (lstFilterType.SelectedItems.Count > 0)
                    {
                        try
                        {
                            string ParValue = null;
                            for (int i = 0; i < lstFilterType.SelectedItems.Count; i++)
                            {
                                string[] strLeadFormatID = ((ListBoxItem)lstFilterType.SelectedItems[i]).Tag.ToString().Split(',');
                                ParValue += strLeadFormatID[0].ToString() + ",";
                                //ParValue=ParValue.Substring(0,ParValue.Length
                            }
                            ParValue = ParValue.Substring(0, ParValue.Length - 1);
                            ClsFilterTypeCollection objFilterColl = ClsFilterTypeCollection.Filter_GetAll(ParValue);
                            ListBox lstFilterTypeTemp = new ListBox();
                            lstFilterTypeTemp.SelectionMode = SelectionMode.Multiple;
                            for (int i = 0; i < objFilterColl.Count; i++)
                            {
                                ListBoxItem cbiFormat = new ListBoxItem();
                                cbiFormat.Content = objFilterColl[i].FilterName;
                                cbiFormat.Tag = objFilterColl[i].ID + "," + objFilterColl[i].FieldId + "," + objFilterColl[i].FieldValues + "," + objFilterColl[i].Operator;
                                //cbiFormat.Tag = objFilterColl[i].ID + "," + objFilterColl[i].FilterName;
                                lstFilterTypeTemp.Items.Add(cbiFormat);
                            }

                            lstFilterTypeTemp.SelectAll();

                            xmlFileData += "<lstFilterType>";
                            for (int i = 0; i < lstFilterTypeTemp.SelectedItems.Count; i++)
                            //for (int i = 0; i < lstFilterType.SelectedItems.Count; i++)
                            {
                                xmlFileData += "<Item value=\"" + ((ListBoxItem)lstFilterTypeTemp.SelectedItems[i]).Tag.ToString() + "\"></Item>";
                                //xmlFileData += "<Item value=\"" + ((ListBoxItem)lstFilterType.SelectedItems[i]).Tag.ToString() + "\"></Item>";
                            }
                            xmlFileData += "</lstFilterType>";
                        }
                        catch (Exception ex)
                        {
                            VMuktiHelper.ExceptionHandler(ex, "condition of a filter for making XML", "CtlImportLeads.xaml.cs");
                        }
                    }
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:101,代码来源:CtlImportLeads.xaml.cs

示例3: bxAddItemsAll

        /// <summary>全アイテム追加</summary>
        public bool bxAddItemsAll(ListBox src, ListBox target, IList trgItemsSource = null)
        {
            if (src == null || target == null) return false;

            if (src.SelectionMode != SelectionMode.Single) src.SelectAll();
            return bxAddItems(src.Items, target, false, trgItemsSource);
        }
开发者ID:nekopanda,项目名称:EDCB,代码行数:8,代码来源:BoxExchangeEditor.cs


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