We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bug with Autocomplete ProcessAutoComplete when the related textbox do not have focus

Thread ID:





49786 Sep 26,2006 08:40 PM UTC Oct 12,2006 07:37 AM UTC WinForms 4
Tags: Tools
Oleg Petruny
Asked On September 26, 2006 08:40 PM UTC

In the submitted code the autocomplete ProcessAutoComplete method generates the exception below when the TextBox doesn’t have focus. In project sample you can recreate the exception by pressing the form button you can avoid the exception by uncomment the row 18 of the files form1.cs (set the focus first).

Is their a way to call autoComplete.ProcessAutoComplete method without having the focus on the field?

What mean the exception generated?

Exception generated:

System.ArgumentNullException was unhandled
Message="Key cannot be null.\r\nParameter name: key"
at Syncfusion.Windows.Forms.Tools.AutoComplete.GetControlAutoMode()
at Syncfusion.Windows.Forms.Tools.AutoComplete.ProcessAutoComplete(String currentText, String selectedEntry, Point location)
at Syncfusion.Windows.Forms.Tools.AutoComplete.ProcessAutoComplete(String currentText)
at WindowsApplication1.AutoCompleteTextBox.ShowAutoComplete() in C:\netSamples\AutocompleteBug\WindowsApplication1\AutoCompleteTextBox.cs:line 42
at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) in C:\netSamples\AutocompleteBug\WindowsApplication1\Form1.cs:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication1.Program.Main() in C:\netSamples\AutocompleteBug\WindowsApplication1\Program.cs:line 14
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Anupama Roy [Syncfusion]
Replied On September 27, 2006 05:02 PM UTC

Hi Oleg,

You can set the TextBox to be the ActiveFocusControl of AutoComplete and can have AutoCompletion even if the TextBox does not have focus.


public void ShowAutoComplete()
this._autoComplete.ActiveFocusControl = this;


Do let us know if you need furthur assistance.



Benoit Marsot
Replied On October 11, 2006 09:31 PM UTC

We try your suggested solution and the behavior is even worst forbidding the access of the AutoComplete unless the mouse is used.

Any suggestion?

Please can you indicated why and/or what is not supposed to be null.

The program implementing your suggestion has been put in attachment.


Benoit Marsot
Replied On October 11, 2006 10:20 PM UTC

I am using:
VS 2005
.net 2.0

Anupama Roy [Syncfusion]
Replied On October 12, 2006 07:37 AM UTC

Hi Benoit,

Whenever a control on a form having AutoComplete component is activated,the AutoCompleteMode needs to be checked so as to autoComplete the text.Inorder to get the AutoCompleteMode for a particular control,it will look whether it has the active focus currently.AutoComplete will not know in which mode it has to AutoComplete as the ActiveFocusControl is null and it will throw NullReferenceException.This was the reason why i suggested to set the ActiveFocusControl property.

Earlier you had mentioned that inorder to reproduce the exception,form button needs to be pressed.I followed the same and while debugging through the source also,I could see that the value in the TextBox is passed correctly to AutoComplete and it did not throw the exception.




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon