Code Red > .NET

C# text boxes syncronising with list boxes

(1/1)

lanks:
In my form i have 3 text boxes, and 3 list boxes. Text box one is linked to list box one, etc. the three list boxes are linked, but only the first list box contains unqiue items. an item from the first and second list box will tell you what item is needed from the third list box.

i am trying to do the following:
as the user types into any of the text boxes, their available options are narrowed down. (similar to a combo box)
i also wish to show the matching items from the other list boxes.

thank you in advance

It's Alive!:
One way is to use events, such as


--- Code: ---private void textBox_TextChanged(object sender, EventArgs e)
--- End code ---

as the user types in the textbox have the event update the listbox.
Here is a hack I did for updating a datagridview from a textbox


--- Code: ---private void textBox1_TextChanged(object sender, EventArgs e)
    {
      try
      {
        string sSearch = this.textBoxSearch.Text.Trim();
        int iCnt = this.dataGridViewProductList.Rows.Count;
        for (int i = 0; i < iCnt; i++)
        {
          if (0 < sSearch.Length)
          {
            DataGridViewCell cell1 = this.dataGridViewProductList[1, i];
            string sCellval = Convert.ToString(cell1.Value);
            while (sCellval.Length < sSearch.Length)
            {
              sCellval += "\x0020";
            }
            string text3 = sCellval.Substring(0, sSearch.Length);
            if (string.Compare(sSearch, text3, true) == 0)
            {
              cell1.Selected = true;
              i = iCnt;
            }
          }
        }
      }
      catch
      {
        this.dataGridViewProductList.ClearSelection();
      }
    }
--- End code ---

Navigation

[0] Message Index

Go to full version