本文整理汇总了C#中System.Web.UI.WebControls.ListBox.ClearSelection方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.ClearSelection方法的具体用法?C# ListBox.ClearSelection怎么用?C# ListBox.ClearSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ListBox
的用法示例。
在下文中一共展示了ListBox.ClearSelection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
HtmlForm frm = (HtmlForm)FindControl("Form1");
GHTTestBegin(frm);
foreach (Type currentType in TestedTypes)
ListControl_ClearSelection(currentType);
// Clearing multiple selected items:
// This cannot be tested in ListControl, because only ListBox can have multiple selection.
GHTSubTestBegin("Clear multiple selection");
System.Web.UI.WebControls.ListBox lb = new System.Web.UI.WebControls.ListBox();
GHTActiveSubTest.Controls.Add(lb);
try
{
lb.Items.Add("A");
lb.Items.Add("B");
lb.Items.Add("C");
lb.Items.Add("D");
lb.SelectionMode = ListSelectionMode.Multiple;
lb.Items[0].Selected = true;
lb.Items[1].Selected = true;
lb.Items[2].Selected = true;
lb.ClearSelection();
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
GHTTestEnd();
}
示例2: SetValue
public static void SetValue(int boField, bool boFieldIsNull, ListBox lb)
{
lb.ClearSelection();
if (boFieldIsNull)
{
return;
}
else
{
ListItem li = lb.Items.FindByValue(boField.ToString());
if (!(li == null))
{
li.Selected = true;
}
}
}
示例3: ListBoxSelect
public static void ListBoxSelect(ref ListBox ddl, string value)
{
ddl.ClearSelection();
ListItem li = ddl.Items.FindByValue(value);
if (li != null)
{
li.Selected = true;
}
}
示例4: CurrentLB_Choose
/// <summary>
/// 把一个LISTBOX中的列表项全部移动到另一个LISTBOX列表项中
/// </summary>
/// <param name="CurrentListBoxFrom">From列表控件</param>
/// <param name="CurrentListBoxTo">To列表控件</param>
/// <param name="istrue">全部移动标识</param>
public static void CurrentLB_Choose(ListBox CurrentListBoxFrom,ListBox CurrentListBoxTo,bool istrue)
{
int i=0,j=0;
j=CurrentListBoxFrom.Items.Count;
ListItem[] CuChoose=new ListItem[j];
foreach(ListItem CuListitem in CurrentListBoxFrom.Items)
if(CurrentListBoxTo.Items.FindByValue(CuListitem.Value)==null)
{
CurrentListBoxTo.Items.Add(CuListitem);
CuChoose[i]=CuListitem;
i++;
}
foreach(ListItem Citm in CuChoose)
CurrentListBoxFrom.Items.Remove(Citm);
CurrentListBoxTo.ClearSelection();
}
示例5: MoveItems
public void MoveItems(bool isAdd, ListBox ListBox1, ListBox ListBox2)
{
if (isAdd)// means if you add items to the right box
{
for (int i = ListBox1.Items.Count - 1; i >= 0; i--)
{
if (ListBox1.Items[i].Selected)
{
ListBox2.Items.Add(ListBox1.Items[i]);
ListBox2.ClearSelection();
ListBox1.Items.Remove(ListBox1.Items[i]);
}
}
}
else // means if you remove items from the right box and add it back to the left box
{
for (int i = ListBox2.Items.Count - 1; i >= 0; i--)
{
if (ListBox2.Items[i].Selected)
{
ListBox1.Items.Add(ListBox2.Items[i]);
ListBox1.ClearSelection();
ListBox2.Items.Remove(ListBox2.Items[i]);
}
}
}
if (ListBox1.Items.Count > 0)
{
ListBox1.SelectedIndex = 0;
}
if (ListBox2.Items.Count > 0)
{
ListBox2.SelectedIndex = 0;
}
}
示例6: SelecionaItemDDL
private void SelecionaItemDDL(ListBox ddl, string qsKey)
{
if (!string.IsNullOrEmpty(Request.QueryString[qsKey]))
{
ListItem item = ddl.Items.FindByValue(Request.QueryString[qsKey]);
if (item != null)
{
ddl.ClearSelection();
item.Selected = true;
}
}
}
示例7: BindListBoxValue
/// <summary>
/// Binds the list box value.
/// </summary>
/// <param name="lstAssetValues">ListBox.</param>
/// <param name="assetValue">The asset value.</param>
private void BindListBoxValue(ListBox lstAssetValues, string assetValue)
{
for (int intIndex = 0; intIndex < lstAssetValues.Items.Count; intIndex++)
{
if (string.Equals(lstAssetValues.Items[intIndex].Text, assetValue))
{
lstAssetValues.ClearSelection();
lstAssetValues.Items[intIndex].Selected = true;
}
}
}