/// <summary> /// Sets the selected index text /// </summary> /// <param name="indexText">text to select</param> public void SelectText(string indexText) { tbLookfor.Text = indexText.Trim(); int idx = lbIndex.FindString(indexText, 0); lbIndex.SelectedIndex = idx; }
private void btnEditAddField_Click(object sender, System.EventArgs e) { string newName = txtNewName.Text.Trim(); if (newName == "") { luke.ShowStatus(resources.GetString("NoFieldName")); return; } int index; if ((index = lstFields.FindString(newName)) == -1) { lstFields.Items.Add(newName); fields.Add(new Field(newName, "", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); fieldsReconstructed.Add(false); lstFields.SelectedIndex = lstFields.Items.Count - 1; } else { // already exist lstFields.SelectedIndex = index; } }
//<Snippet1> private void FindAllOfMyString(string searchString) { // Set the SelectionMode property of the ListBox to select multiple items. listBox1.SelectionMode = SelectionMode.MultiExtended; // Set our initial index variable to -1. int x = -1; // If the search string is empty exit. if (searchString.Length != 0) { // Loop through and find each item that matches the search string. do { // Retrieve the item based on the previous index found. Starts with -1 which searches start. x = listBox1.FindString(searchString, x); // If no item is found that matches exit. if (x != -1) { // Since the FindString loops infinitely, determine if we found first item again and exit. if (listBox1.SelectedIndices.Count > 0) { if (x == listBox1.SelectedIndices[0]) { return; } } // Select the item in the ListBox once it is found. listBox1.SetSelected(x, true); } }while(x != -1); } }
private void btnEditAddField_Click(object sender, System.EventArgs e) { string newName = txtNewName.Text.Trim(); if (newName == "") { luke.ShowStatus(resources.GetString("NoFieldName")); return; } int index; if ((index = lstFields.FindString(newName)) == -1) { lstFields.Items.Add(newName); //Lucene.Net_1_4_3_RC3_final: public Field(System.String name, System.String string_Renamed, bool store, bool index, bool token):this(name, string_Renamed, store, index, token, false) //fields.Add(new Field(newName, "", false, false, false)); fields.Add(new Field(newName, "", Field.Store.NO, Field.Index.NO)); fieldsReconstructed.Add(false); lstFields.SelectedIndex = lstFields.Items.Count - 1; } else { // already exist lstFields.SelectedIndex = index; } }
private void btnAdd_Click(object sender, System.EventArgs e) { ushort id; ushort frequency; try { id = Convert.ToUInt16(textBoxTemplateId.Text); frequency = Convert.ToUInt16(textBoxFrequency.Text); if (id < 256) { MessageBox.Show(this, "Invalid Template Id"); textBoxTemplateId.Focus(); DialogResult = DialogResult.None; return; } foreach (netflow.V9Template t in parent.TemplateList) { if (id == t.TemplateId) { MessageBox.Show(this, "The specified template id is already used."); textBoxTemplateId.Focus(); DialogResult = DialogResult.None; return; } } if (frequency <= 10) { if (MessageBox.Show(this, "The template send frequency is too low. Are you sure you want to do this?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No) { textBoxFrequency.Focus(); return; } } } catch (FormatException fe) { MessageBox.Show(this, fe.Message); textBoxTemplateId.Focus(); DialogResult = DialogResult.None; return; } netflow.V9Template template = new netflow.V9Template(id); template.SendFrequency = frequency; foreach (string item in listBoxSelected.Items) { ushort type = 0; ushort length; int i = listBoxAll.FindString(item); if (i != -1) { type = (ushort)(i + 1); } length = TemplateItemSize[type - 1, 1]; template.AddField(type, length); } parent.TemplateList.Add(template); DialogResult = DialogResult.OK; }
/// <summary> /// Constructs a ShowDonorPanel object /// </summary> /// <param name="sales"></param> public ShowDonorPanel(ListBox list, string selectedName) { // sales should be from the same donor InitializeComponent(); initialize(); listBoxResults.Items.AddRange(list.Items); listBoxResults.SelectedIndex = list.FindString(selectedName); selectBrickImage(null, null, null); }
public void SortNodes() { string txt = null; var item = nodes_list.SelectedItem; if (item != null) { txt = item.ToString(); } node_gen.SortNodes(); nodes_list.Items.Clear(); nodes_list.Items.AddRange(node_gen.all_nodes.ToArray()); if (item != null) { int ind = nodes_list.FindString(txt); nodes_list.SelectedIndex = ind; } }
private void SelectDrive_Load(object sender, System.EventArgs e) { string[] drives = System.IO.Directory.GetLogicalDrives(); lstDrives.DataSource = drives; // Select the current drive. lstDrives.SelectedIndex = lstDrives.FindString(DriveSelection.ToString()); // Attach the event handler. // This step is performed after the selected index is set, // to prevent it from being overwritten as the list is built. lstDrives.SelectedIndexChanged += new EventHandler(lstDrives_SelectedIndexChanged); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (((context != null) && (context.Instance != null)) && (provider != null)) { base.editorService = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); if (base.editorService == null) { return value; } ListBox box1 = new ListBox(); float[] singleArray1 = new float[] { 8f, 9f, 10f, 11f, 12f, 13f, 14f, 16f, 18f, 20f, 22f, 24f, 26f, 28f, 36f, 48f, 72f, 80f, 88f, 96f, 128f, 168f } ; for (int num1 = 0; num1 < singleArray1.Length; num1++) { box1.Items.Add(singleArray1[num1]); } singleArray1 = null; box1.BorderStyle = BorderStyle.None; box1.Height = 150; box1.Width = 80; if(value!=null) { //Struct.Float fl= (Struct.Float) value; float f1 = (float)value; box1.SelectedIndex = box1.FindString(f1.ToString()); } box1.SelectedIndexChanged += new EventHandler(this.selectedIndexChanged); base.editorService.DropDownControl(box1); if (this.selectChanged && (box1.SelectedItem != null)) { try { //value =new Struct.Float( float.Parse(box1.SelectedItem.ToString())); value = float.Parse(box1.SelectedItem.ToString()); } catch { } } this.selectChanged = false; } return value; }
private void button1_Click(object sender, System.EventArgs e) { if (textBox1.Text == "") { return; } string strAdd = textBox1.Text; if (listBox1.FindString(strAdd, -1) < 0) { listBox1.Items.Add(strAdd); textBox1.Text = ""; textBox1.Focus(); return; } MessageBox.Show("\"" + strAdd + "\" is already in the list box", "Duplicate"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the list of Header/Footer sets /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateNameBox(string nameToSelect) { m_lstBoxName.Items.Clear(); foreach (IPubHFSet hfSet in m_HfSetOwner.HeaderFooterSetsOC) { m_lstBoxName.Items.Add(hfSet); } if (m_lstBoxName.Items.Count > 0) { int i = (string.IsNullOrEmpty(nameToSelect) ? m_lstBoxName.Items.Count - 1 : m_lstBoxName.FindString(nameToSelect)); m_lstBoxName.SelectedIndex = (i >= 0 ? i : 0); } }
/// <summary> addUitlening voegt een nieuwe uitlening toe. /// <para>Er wordt een nieuwe uitlening in de Database aangemaakt mbv de gegeven parameters.</para> /// </summary> /// <param name="Reserveringsnummer">Het reserveringsnummer van de klant.</param> /// <param name="mat">Het materiaal dat de klant wil lenen.</param> /// <param name="Uitgeleend">De datum waarop de uitlening van start gaat.</param> /// <param name="Ingeleverd">De datum waarop het materiaal uiterlijk teruggebracht moet worden.</param> /// <param name="lBox">De listbox met beschikbare materiaal dat al door de klant gehuurd wordt (Wordt gebruikt om te kijken of er een INSERT of UPDATE SQL commando uitgevoerd moet worden.</param> public static void addUitlening(int Reserveringsnummer, Materiaal mat, DateTime Uitgeleend, DateTime Ingeleverd, ListBox lBox) { { if (lBox.FindString(mat.Type) == ListBox.NoMatches) { string nieuwuitleningins = "INSERT INTO UITLENING (RESERVERINGSNUMMER, TYPE, BETAALD, DATUM_UITGELEEND, DATUM_INGELEVERD, AANTAL) VALUES(" + Reserveringsnummer + ", " + "'" + mat.Type + "', '" + "', '" + Uitgeleend.ToString("dd/MM/yyyy") + "', '" + Ingeleverd.ToString("dd/MM/yyyy") + "', 1)"; OracleCommand insertuitleningcmd = new OracleCommand(nieuwuitleningins, conn); try { conn.Open(); insertuitleningcmd.ExecuteNonQuery(); } catch (Exception ef) { System.Windows.Forms.MessageBox.Show(ef.Message); } finally { conn.Close(); } } else { string sqlverhoogaantal = "UPDATE UITLENING SET AANTAL = AANTAL + 1 WHERE (RESERVERINGSNUMMER = " + Reserveringsnummer + " AND TYPE = '" + mat.Type + "')"; OracleCommand verhoogcmd = new OracleCommand(sqlverhoogaantal, conn); try { conn.Open(); verhoogcmd.ExecuteNonQuery(); } catch (Exception fe) { MessageBox.Show(fe.Message); } finally { conn.Close(); } } } }
//<Snippet1> private void FindMyString(string searchString) { // Ensure we have a proper string to search for. if (!string.IsNullOrEmpty(searchString)) { // Find the item in the list and store the index to the item. int index = listBox1.FindString(searchString); // Determine if a valid index is returned. Select the item if it is valid. if (index != -1) { listBox1.SetSelected(index, true); } else { MessageBox.Show("The search string did not match any items in the ListBox"); } } }
//<Snippet1> private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { // Get the currently selected item in the ListBox. string curItem = listBox1.SelectedItem.ToString(); // Find the string in ListBox2. int index = listBox2.FindString(curItem); // If the item was not found in ListBox 2 display a message box, otherwise select it in ListBox2. if (index == -1) { MessageBox.Show("Item is not available in ListBox2"); } else { listBox2.SetSelected(index, true); } }
private void button1_Click(object sender, System.EventArgs e) { try { if (textBox1.Text.Length != 0) { int index = -1; if (!textBox1.Text.StartsWith(".")) { textBox1.Text = "." + textBox1.Text; } if (-1 != (index = listBox1.FindString(textBox1.Text))) { MessageBox.Show(textBox1.Text + " is already supported extension."); listBox1.SelectedIndex = index; } else { RegistryKey subKeys = Registry.ClassesRoot.OpenSubKey(textBox1.Text + "\\PersistentHandler", true); if (subKeys == null) { subKeys = Registry.ClassesRoot.CreateSubKey(textBox1.Text + "\\PersistentHandler"); } subKeys.SetValue("", GUID); index = listBox1.Items.Add(textBox1.Text); listBox1.SelectedIndex = index; textBox1.Text = ""; } } else { MessageBox.Show(textBox1.Text + " is not a valid file extension."); } } catch (Exception exc) { MessageBox.Show("Cannot add to the extension to the registry./n" + exc); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (((context != null) && (context.Instance != null)) && (provider != null)) { base.editorService = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); if (base.editorService == null) { return value; } if(value==null)return value; ListBox box1 =new ListBox(); if (value is SvgElement ) { XmlNodeList list = (value as SvgElement).OwnerDocument.GetElementsByTagName("layer"); foreach(Layer layer in list) { if (layer !=null) { box1.Items.Add(layer); } } } box1.BorderStyle = BorderStyle.None; box1.Height = 150; box1.SelectedIndex = box1.FindString(value.ToString()); box1.SelectedIndexChanged += new EventHandler(this.selectedIndexChanged); base.editorService.DropDownControl(box1); if (this.selectChanged && (box1.SelectedItem != null)) { value = box1.SelectedItem; } this.selectChanged = false; } return value; }
private void txtLookfor_TextChanged(object sender, System.EventArgs e) { lstAvailableFuncs.SelectedIndex = lstAvailableFuncs.FindString(txtLookfor.Text); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { // Uses the IWindowsFormsEditorService to display a // drop-down UI in the Properties window. IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { // Display an angle selection control and retrieve the value. ListBox lb = new ListBox(); lb.BorderStyle = BorderStyle.None; lb.Dock = DockStyle.Fill; lb.Height = 250; lb.Tag = edSvc; lb.SelectedIndexChanged += new EventHandler(lb_SelectedIndexChanged); lb.Items.Add(string.Empty); // no genre foreach (string gi in ID3FileInfo.AudioGenres) { lb.Items.Add(gi); } lb.SelectedIndex = lb.FindString(value as string); edSvc.DropDownControl(lb); return (string)lb.SelectedItem; } return value; }