NRE opening combobox dropdown menu

A

Andrus

SWF DataGridView contains combobox control.
Activating combobox and pressing F4 to open dropdown menu causes strange NRE
(see below).

When I enter some valid value to combobox, press tab, shift+tab , 44
dropdown menu opens OK.

How to fix ?

How to use VCSE 2008 with .net framework source code to find the line in

System.Windows.Forms.DataGridViewComboBoxCell.ComboBox_DropDown()

which causes this error ?


Andrus.

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="System.Windows.Forms"
StackTrace:
at
System.Windows.Forms.DataGridViewComboBoxCell.ComboBox_DropDown(Object
sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnDropDown(EventArgs e)
at myApp.myComboBox.OnDropDown(EventArgs e) in myComboBox.cs:line 71
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.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam,
IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd,
Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.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.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.ComboBox.DefChildWndProc(Message& m)
at System.Windows.Forms.ComboBox.ChildWndProc(Message& m)
at
System.Windows.Forms.ComboBox.ComboBoxChildNativeWindow.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)
.....
 
M

Morten Wennevik [C# MVP]

Hi Andrus,

I was just about to ignore your post as a third party control issue when I
discovered the meaning of your abbreviations (you might want to be more
careful in using them as other people might not have a clue what they mean).
I assume NRE = NullReferenceException and SWF = System.Windows.Forms.

I was unable to reproduce your issue using a simple DataGridView and a
ComboBoxColumn. F4 worked just as expected. It does, however, appear that
you have a custom ComboBox control in the grid and I would take a closer look
at line 71 in myComboBox.cs.

If by VCSE you mean Visual C# Express I'm not sure if stepping into .Net
Framework libraries is available, but you can try

http://weblogs.asp.net/scottgu/arch...rce-code-for-the-net-framework-libraries.aspx
 
A

Andrus

I was unable to reproduce your issue using a simple DataGridView and a
ComboBoxColumn. F4 worked just as expected. It does, however, appear
that
you have a custom ComboBox control in the grid and I would take a closer
look
at line 71 in myComboBox.cs.

line 71 is only line, base.OnDropDown(e) in OnDropDown()

protected override void OnDropDown(System.EventArgs e) {
base.OnDropDown(e);

}

after I removed this line by creating empty procedure:

protected override void OnDropDown(System.EventArgs e) {

}

NullReferenceException disappears.

Any idea why ?

Andrus.
 
M

Morten Wennevik [C# MVP]

Andrus said:
line 71 is only line, base.OnDropDown(e) in OnDropDown()

protected override void OnDropDown(System.EventArgs e) {
base.OnDropDown(e);

}

after I removed this line by creating empty procedure:

protected override void OnDropDown(System.EventArgs e) {

}

NullReferenceException disappears.

Any idea why ?

Andrus.

I couldn't say. If you have VS 2008 you could try stepping into the
base.OnDropDown(e) method and see what it does.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top