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


C# ListBox.ClearSelection方法代码示例

本文整理汇总了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();

		}
开发者ID:nobled,项目名称:mono,代码行数:34,代码来源:ListControl_ClearSelection_.aspx.cs

示例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;
         }
     }
 }
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:16,代码来源:UICommon.cs

示例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;
     }
 }
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:9,代码来源:UICommon.cs

示例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();			
		}
开发者ID:yftiger1981,项目名称:WlnPsyWeb,代码行数:22,代码来源:ZhNetLibrary.cs

示例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;
     }
 }
开发者ID:knkbhatia,项目名称:materialallocationatconstructionsite,代码行数:35,代码来源:OracleDataAccess.cs

示例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;
				}
			}
		}
开发者ID:ops-org,项目名称:ops.net.br,代码行数:12,代码来源:PesquisaPrincipal.aspx.cs

示例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;
         }
     }
 }
开发者ID:vijaymca,项目名称:Dotnet,代码行数:16,代码来源:AddChapter.ascx.cs


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