本文整理汇总了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);
}
}
示例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");
}
}
//.........这里部分代码省略.........
示例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);
}