Results 1 to 7 of 7

Thread: [2.0] Trigger combobox dropdown list

Threaded View

  1. #5

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [2.0] Drigger combobox dropdown list

    I changed the style to 'simple' and changing the member variable as you said didn't work. Changing the styly to 'dropdown' did though, so thanks for that.

    I've got another problem now though. All i did was add the line 'cboRunThis.DroppedDown = true;' in my text changed event and now the mouse disappears when it's over my program.

    I guess the problem is that i'm updating the list in a seperate thread, but i'm doing that ok i think (by calling invoke if required, using code from MSDN). It doesn't make the cursor disappear if i manually click the combobox to show the list, plus the list is updated as appropriate then.

    I'm just not sure why it should be a problem when i'm updating the list in another thread.

    Any thoughts on this would be appreciated.

    EDIT:

    Now as soon as the list had items then has none i get the following error...

    Code:
    System.ArgumentOutOfRangeException: InvalidArgument=Value of '0' is not valid for 'index'.
    Parameter name: index
       at System.Windows.Forms.ComboBox.ObjectCollection.get_Item(Int32 index)
       at System.Windows.Forms.ComboBox.get_Text()
       at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    I have no idea what could be wrong with my code, since that isn't my code.
    I've tried removing every line where i dropdown the list, so i'm really stumped as to what's going wrong. I guess it's to do with the way i'm updating the list, so here's the code my thread is using to update the list.

    Code:
    public void AddItem(string Item, ComboBox DisplayBox)
            {
                if (DisplayBox.InvokeRequired)
                {
                    AddItemCallback CallBack = new AddItemCallback(AddItem);
                    this.Invoke(CallBack, new object[] { Item, DisplayBox });
                }
                else
                {
                    int CursorPos = DisplayBox.SelectionStart;
                    DisplayBox.Items.Add(Item);
                    DisplayBox.SelectionStart = CursorPos;
                }
            }
    and here's the code i use in the textchanged event that clears the combobox's list, and aborts the worker thread (and creates a new worker thread).

    Code:
    private void cboRunThis_TextChanged(object sender, EventArgs e)
            {
                WorkerParameters Params = new WorkerParameters();
                if (WorkerThread.IsAlive)
                {
                    WorkerThread.Abort();
                    WorkerThread.Join();
                }
                if (cboRunThis.Text.Length == 0)
                    return;
                FoundItemsQueue.Clear();
                int CursorPos = cboRunThis.SelectionStart;
                cboRunThis.Items.Clear();
                cboRunThis.SelectionStart = CursorPos;
    
                if (cboRunThis.Text.Contains("/"))
                    return;
                WorkerThread = new Thread(Job);
                Params.SearchString = cboRunThis.Text;
                Params.DisplayBox = cboRunThis;
                WorkerThread.Start(Params);
            }
    Last edited by SLH; Apr 21st, 2006 at 10:40 PM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width