I have a radgridview that is databound to a llblgen entity collection (implements IListSource) . One property of the actual databound object (entity) is a nulalble int. This property is set by a GridViewComboBoxColumn. When a new entity is added to the llblgen entity collection after the llblgen entity collection is databound to the radgridview the new row is automatically added to the radgridview but when the user changes the nullable property a NullReferenceException occurs:
bij Telerik.WinControls.UI.GridDataCellElement.SetContentCore(Object value)
bij Telerik.WinControls.UI.GridDataCellElement.SetContent()
bij Telerik.WinControls.UI.GridTableElement.InvalidateRow(GridViewRowInfo rowInfo)
bij Telerik.WinControls.UI.GridViewRowInfo.InvalidateRow()
bij Telerik.WinControls.UI.RadGridView.OnLostFocus(EventArgs e)
bij System.Windows.Forms.Control.WndProc(Message& m)
bij System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bij Telerik.WinControls.RadControl.WndProc(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bij System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
bij System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
bij System.Windows.Forms.NativeWindow.DestroyHandle()
bij System.Windows.Forms.Control.DestroyHandle()
bij System.Windows.Forms.Control.Dispose(Boolean disposing)
bij System.Windows.Forms.Form.Dispose(Boolean disposing)
bij Bouwfonds.GEMS.GUI.WF.uiHoofdFrm.Dispose(Boolean disposing)
bij System.ComponentModel.Component.Dispose()
bij System.Windows.Forms.ApplicationContext.Dispose(Boolean disposing)
bij System.Windows.Forms.Application.ThreadContext.DisposeThreadWindows()
Any idea’s?
Many tanx in advance!
11 Answers, 1 is accepted
Can you provide us with a sample project that demonstrates the case? If so please open a regular support ticket and send us your demo application.
Kind regards,
Dimitar Kapitanov
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Today I have encountered a similar probme:
StackTrace + Exception:
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.WinControls.UI.RadGridView.OnLostFocus(EventArgs e) at System.Windows.Forms.Control.WmKillFocus(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.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) Telerik.WinControls.UI Assembly Version: 2012.1.321.20 Win32 Version: 2012.1.321.20 CodeBase: file:///D:/Lucru/PLC_empty/Telerik.WinControls.UI.DLL ---------------------------------------- Telerik.WinControls Assembly Version: 2012.1.321.20 Win32 Version: 2012.1.321.20 CodeBase: file:///D:/Lucru/PLC_empty/Telerik.WinControls.DLL ---------------------------------------- Telerik.WinControls.Themes.Windows7 Assembly Version: 2012.1.321.20 Win32 Version: 2012.1.321.20 CodeBase: file:///D:/Lucru/PLC_empty/Telerik.WinControls.Themes.Windows7.DLL ---------------------------------------- Telerik.WinControls.Themes.Office2010Blue Assembly Version: 2012.1.321.20 Win32 Version: 2012.1.321.20 CodeBase: file:///D:/Lucru/PLC_empty/Telerik.WinControls.Themes.Office2010Blue.DLL ---------------------------------------- TelerikCommon Assembly Version: 2012.1.321.20 Win32 Version: 2012.1.321.20 CodeBase: file:///D:/Lucru/PLC_empty/TelerikCommon.DLL ----------------------------------------
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Code line error: ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition(); ...
Symptoms:
The error seems to be cause if I do multiple operations in close proximity (repopulate, redo radGridView.ViewDefinition set).
I have no 100% way to reproduce the error.
The grid has a column with texts (readonly) that is pinned. The rest of the grid is populated with CheckBoxColumns.
Can you give me a clue about what could cause this error?
Thank you.
Judging by your description I can say that this is not a known issue. I would kindly ask you to provide me with additional details about your scenario. It will be best if you can send us a sample project where we can reproduce the issue. This will allow us to understand the exact behavior and the circumstances in which it occurs. Hence we will be able to assist you further.
Thank you for your cooperation. I am looking forward to your reply.
Regards, Julian Benkov
the Telerik team
I have a similar issue with the latest trial version.
I have on form:
- RadGridView with databound items. (Typed Datatable, Bindingsource)
- GridViewComboboxColumn with databound items (Typed Datatable, Bindingsource)
GridViewComboBoxColumn3.DataSource = Me.AllapotokBindingSource
GridViewComboBoxColumn3.DataType = GetType(Byte)
GridViewComboBoxColumn3.DisplayMember = "AllapotNev"
GridViewComboBoxColumn3.EnableExpressionEditor = False
GridViewComboBoxColumn3.FieldName = "AllapotId"
GridViewComboBoxColumn3.HeaderText = "Állapot"
GridViewComboBoxColumn3.Name = "Allapot"
GridViewComboBoxColumn3.ValueMember = "ID"
GridViewComboBoxColumn3.Width = 84
There are no additional code behind my form that is related to RadGridView.
The issue:
If I sort the GridViewComboBoxColumn3 at runtime, and I change a cell value to another value and I click to another row, the following error message shown:
System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.WinControls.GridView.dll
Additional information: Az objektumhivatkozás nincs beállítva semmilyen objektumpéldányra.
System.NullReferenceException: Az objektumhivatkozás nincs beállítva semmilyen objektumpéldányra.
a következő helyen: Telerik.WinControls.UI.GridComboBoxCellElement.SetContent()
a következő helyen: Telerik.WinControls.UI.GridDataCellElement.set_Value(Object value)
a következő helyen: Telerik.WinControls.UI.GridViewEditManager.EndEditCore(Boolean validate, Boolean cancel)
a következő helyen: Telerik.WinControls.UI.GridViewEditManager.OnPositionChanging(PositionChangingEventArgs args)
a következő helyen: Telerik.WinControls.UI.GridViewEditManager.Telerik.WinControls.UI.IGridViewEventListener.PreProcessEvent(GridViewEvent eventData)
a következő helyen: Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
a következő helyen: Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
a következő helyen: Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
a következő helyen: Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
a következő helyen: Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
a következő helyen: Telerik.WinControls.UI.BaseGridNavigator.SelectCore(GridViewRowInfo row, GridViewColumn column)
a következő helyen: Telerik.WinControls.UI.GridRowBehavior.SelectPositionOnMouseDownLeft(MouseEventArgs e, GridRowElement rowElement, GridCellElement cellElement)
a következő helyen: Telerik.WinControls.UI.GridRowBehavior.OnMouseDownLeft(MouseEventArgs e)
a következő helyen: Telerik.WinControls.UI.GridRowBehavior.OnMouseDown(MouseEventArgs e)
a következő helyen: Telerik.WinControls.UI.BaseGridBehavior.OnMouseDown(MouseEventArgs e)
a következő helyen: Telerik.WinControls.UI.RadGridView.OnMouseDown(MouseEventArgs e)
a következő helyen: System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
a következő helyen: System.Windows.Forms.Control.WndProc(Message& m)
a következő helyen: Telerik.WinControls.RadControl.WndProc(Message& m)
a következő helyen: System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Best Regards,
László
Thank you for writing.
Following the provided information I have tried to reproduce the issue you are facing but without any success. Here is my sample code snippet:
public
Form1()
{
InitializeComponent();
DataTable gridSource =
new
DataTable();
gridSource.Columns.Add(
"Id"
,
typeof
(
int
));
gridSource.Columns.Add(
"Name"
,
typeof
(
string
));
for
(
int
i = 0; i < 50; i++)
{
gridSource.Rows.Add(i, i);
}
DataTable comboSource =
new
DataTable();
comboSource.Columns.Add(
"ContactID"
,
typeof
(
int
));
comboSource.Columns.Add(
"ContactName"
,
typeof
(
string
));
for
(
int
i = 0; i < 50; i++)
{
comboSource.Rows.Add(i,
"Name"
+ i);
}
this
.radGridView1.AutoGenerateColumns =
false
;
GridViewDecimalColumn decimalColumn =
new
GridViewDecimalColumn(
"ID column"
);
decimalColumn.FieldName =
"Id"
;
radGridView1.Columns.Add(decimalColumn);
GridViewComboBoxColumn comboCol =
new
GridViewComboBoxColumn(
"Name column"
);
comboCol.DataSource = comboSource;
comboCol.ValueMember =
"ContactID"
;
comboCol.DisplayMember =
"ContactName"
;
comboCol.FieldName =
"Name"
;
radGridView1.Columns.Add(comboCol);
radGridView1.DataSource = gridSource;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
The attached gif file illustrates better the behavior on my end. Am I missing something? Could you please modify my sample code snippet on a way to replicate the described problem and get back to me with it. Thus, we would be able to investigate the precise case and assist you further. Thank you in advance for the co-operation.
I am looking forward to your reply.
Regards,
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you for reply! I try to reproduce the issue in a smaller application, without success, I have no idea what is the problem in first case. :) Some additional information:
- I have an SQL Server database -> The SQL table contains 2 computed columns, a foreign key column and "not null" and nullable columns also.
- In the test project I have a typed dataset with typed datatables. The gridview datasource is a BindingSource.
- I have multiple columns with same FieldName (a combobox column and a textbox column that shows the same data).
I think some object is Nothing in these methods:
a következő helyen: Telerik.WinControls.UI.GridComboBoxCellElement.SetContent()
a következő helyen: Telerik.WinControls.UI.GridDataCellElement.set_Value(Object value)
If you can send me a compiled dll with some debug code in these methods, I can test it with my application. (If this is a possible way of the issue detection. :))
This is not a big problem for me, I test the controls now. If I can reproduce the issue in the future, I will write a post.
Best Regards,
László
Thank you for writing back.
Without a reproducible scenario or a sample code snippet which replicates the issue we can make only conjectures what is causing the issue. That is why I would kindly ask you to isolate the problem in a sample project and open a support ticket with it. Thus, we would be able to investigate the precise case and assist you further. Thank you in advance.
Additionally, when you are a licensed developer you are allowed to download the source code. You can refer to our Download Product Files help article.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
After long hours I succeed to reproduce the issue. I open a new ticket with a sample project here:
http://feedback.telerik.com/Project/154/Feedback/Details/151017-radgridview-gridviewcomboboxcolumn-nullreferenceexception-on-cellvaluechanged
Thank you!
Thank you for writing back.
The provided sample project and video are greatly appreciated. I confirm this is an issue with GridComboBoxCellElement in RadGridView. However, it is related to FIX. RadGridView - NullReference exception when using message box in CellValueChanged event feedback item which fix will be introduced in the upcoming Q1 2015 release.
I have also updated your Telerik points for reporting this issue.
Currently, the possible solution that I can suggest is to create a custom GridComboBoxCellElement as follows:Private
Sub
gridMunkak_CreateCell(sender
As
Object
, e
As
GridViewCreateCellEventArgs)
Handles
gridMunkak.CreateCell
If
e.CellType =
GetType
(GridComboBoxCellElement)
Then
e.CellElement =
New
MyGridComboBoxCellElement(e.Column, e.Row)
End
If
End
Sub
Public
Class
MyGridComboBoxCellElement
Inherits
GridComboBoxCellElement
Public
Sub
New
(column
As
GridViewColumn, row
As
GridRowElement)
MyBase
.
New
(column, row)
End
Sub
Public
Overrides
Sub
SetContent()
If
Me
.ColumnInfo IsNot
Nothing
Then
MyBase
.SetContent()
End
If
End
Sub
Protected
Overrides
ReadOnly
Property
ThemeEffectiveType()
As
Type
Get
Return
GetType
(GridComboBoxCellElement)
End
Get
End
Property
End
Class
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
All, I am using a pre 1stQ 2015 version of Telerik RadControls and ran into this problem. To get around it, I subclass the RadMultiColumnComboBox and override the OnLostFocus event handler as follows:
public
class
RadMultiColumnComboBoxSnc : RadMultiColumnComboBox {
protected
override
void
OnLostFocus(EventArgs e) {
try
{
base
.OnLostFocus(e);
}
catch
(NullReferenceException nrex) {
if
(!(nrex.Source ==
"Telerik.WinControls.GridView"
&& nrex.TargetSite.Name.Equals(
"OnLostFocus"
))) {
throw
;
}
} } }
This way, only null reference exceptions that are from the grid view and come from the on lost focus event handler get swallowed.
Thank you for writing.
The referred feedback item is related to RadGridView and its GridViewComboBoxColumn. Could you please specify in details what is the exact scenario in which you encounter the NullReferenceException and how the RadMultiColumnComboBox is related to this issue? A sample code snippet demonstrating how to replicate the issue locally would be greatly appreciated. Thus, we would be able to make an adequate analysis of the problem and assist you further. Thank you in advance.
I am looking forward to your reply.
Regards,
Dess
Telerik