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(); }
private void cmdUp_Click(object sender, System.EventArgs e) { int intX = 0; int intY = 0; try { ListItem objMyListItem; objMyListItem = lstItems.SelectedItem; foreach (ListItem tmpListItem in lstItems.Items) { if (tmpListItem.Selected == true) { intY = intX; if (intY == 0) { return; } } intX = intX + 1; } lstItems.Items.Remove(objMyListItem); lstItems.ClearSelection(); lstItems.Items.Insert(intY - 1, objMyListItem); intX = 0; foreach (ListItem tmpListItem in lstItems.Items) { listItemsDataAccess.updateOrder(System.Convert.ToInt32(tmpListItem.Value), intX); intX++; } page_bind(); } catch (System.Exception ex) { string strTmp = ex.Message; return; } }
private void AddMore_Click(object sender, System.EventArgs e) { NumberOfPeople.Text = ""; CompanyName.ReadOnly = true; ReprName.ReadOnly = true; Telephone.ReadOnly = true; StartDate.ReadOnly = true; ReturnDate.ReadOnly = true; BrowseCalendar1.Enabled = false; BrowseCalendar2.Enabled = false; Total.Text = ""; DDLDestination.EnableViewState = true; DDLDestination.Enabled = false; DDLVehicleType.ClearSelection(); ListVehicles.ClearSelection(); Save.Enabled = true; AddMore.Enabled = false; }
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(); }
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; } } }
public static void ListBoxSelect(ref ListBox ddl, string value) { ddl.ClearSelection(); ListItem li = ddl.Items.FindByValue(value); if (li != null) { li.Selected = true; } }
/// <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(); }
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; } }
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; } } }
private void ShowSelectedTestInformation(string testID) { // Make the test panel visible... AreaInfoPanel.Visible = false; TestEditPanel.Visible = true; HistoryPanel.Visible = false; TestEditLabel.Text = "Edit/View Test"; Test testInformation = dbConnection.RetrieveTest(testID); EditTestTestName.Text = testInformation.Name; EditTestTestDescription.Text = testInformation.Description; // First, clear out the test owners list... EditTestOwnerList.Items.Clear( ); // Populate the owner list... foreach (User user in dbConnection.RetrieveAllUsers( )) { EditTestOwnerList.Items.Add(new ListItem(user.Name, user.Name)); } // Set the currently selected item to the test owner in the user list... EditTestOwnerList.SelectedValue = dbConnection.RetrieveUser(testInformation.OwnerID).Name; // Clear any selections in the priority list box... EditTestTestPriorityListBox.ClearSelection( ); // Now, select the current priority given to the test... ListItem priorityItem = EditTestTestPriorityListBox.Items.FindByText("P" + testInformation.Priority); if (priorityItem != null) { priorityItem.Selected = true; } EditTestExecutionPath.Text = testInformation.ExecutionPath; EditTestExecutionName.Text = testInformation.ExecutionBinary; EditTestExecutionArgs.Text = testInformation.ExecutionArgs; if (EditTestOS.Items.FindByValue(testInformation.OperatingSystem) != null) { EditTestOS.SelectedValue = testInformation.OperatingSystem; } if (EditTestOSVersion.Items.FindByValue(testInformation.OSVersion) != null) { EditTestOSVersion.SelectedValue = testInformation.OSVersion; } // Figure out the date and time components of the interval and set them... RunFrequency runFrequency = new RunFrequency(testInformation.RunFrequency); RunFreqMonths.Text = (runFrequency.Interval.Days / 30).ToString( ); // Get number of months... RunFreqDays.Text = (runFrequency.Interval.Days % 30).ToString( ); // Get number of days (left from months)... RunFreqHours.Text = runFrequency.Interval.Hours.ToString( ); RunFreqMinutes.Text = runFrequency.Interval.Minutes.ToString( ); EditTestRunNumberOfTimes.Text = runFrequency.RunNumberOfTimes.ToString( ); if (runFrequency.RunInfinite) { EditTestInfinite.Checked = true; EditTestInfiniteNoCare.Checked = false; } else { EditTestInfiniteNoCare.Checked = true; EditTestInfinite.Checked = true; } EditTestState.Text = testInformation.State; EditTestInternalID.Text = testInformation.ID; }
/// <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; } } }
protected void clearSelection_Click(object sender, EventArgs args) { list.ClearSelection(); }