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...
I have no idea what could be wrong with my code, since that isn't my code.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'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.
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: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; } }
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); }






Reply With Quote