I have the following code in the event
private void mccbSelectTheme_SelectedValueChanged(object sender, EventArgs e)
{
string cc = mccbSelectTheme.EditorControl.CurrentRow.Cells[1].Value.ToString();
}
I keep getting a System.Null reference exception when I click the dropdown arrow.
The control is loaded with2 columns with column 1 not visible.
11 Answers, 1 is accepted
Hello, Claude,
Following the provided information I created a MultiColumnComboBox with two columns, first of them is not visible. However, I am not receiving an error when clicking on the dropdown arrow. You can see the result on my end in the attached gif file. Below is my sample project:
public RadForm1()
{
InitializeComponent();
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Employee", typeof(string));
table.Rows.Add(25, "David");
table.Rows.Add(50, "Sam");
table.Rows.Add(10, "Christoff");
table.Rows.Add(21, "Janet");
table.Rows.Add(100, "Melanie");
this.radMultiColumnComboBox1.DataSource = table;
this.radMultiColumnComboBox1.Columns[0].IsVisible = false;
this.radMultiColumnComboBox1.EditorControl.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radMultiColumnComboBox1.SelectedValueChanged += this.RadMultiColumnComboBox1_SelectedValueChanged;
}
private void RadMultiColumnComboBox1_SelectedValueChanged(object sender, EventArgs e)
{
string cc = radMultiColumnComboBox1.EditorControl.CurrentRow.Cells[1].Value.ToString();
}
Could you give it a try and let me know how it differs from your set up. Am I missing something?
I am looking forward to your reply.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Here is my code. Also attached error message when I click on the dropdown
private void frmSettings_Load(object sender, EventArgs e)
{
ThemeResolutionService.ApplicationThemeName = "Desert";
//disable event
this.mccbSelectTheme.SelectedValueChanged -= this.mccbSelectTheme_SelectedValueChanged;
this.mccbSelectTheme.MultiColumnComboBoxElement.Columns.Add("Name");
this.mccbSelectTheme.MultiColumnComboBoxElement.Columns.Add("Id");
mccbSelectTheme.Columns[1].IsVisible = false;
this.mccbSelectTheme.EditorControl.Rows.Add("Aqua", "Aqua");
this.mccbSelectTheme.EditorControl.Rows.Add("Breeze", "Breeze");
this.mccbSelectTheme.EditorControl.Rows.Add("Desert", "Desert");
this.mccbSelectTheme.EditorControl.Rows.Add("Fluent", "Fluent");
this.mccbSelectTheme.EditorControl.Rows.Add("Fluent Dark", "FluentDark");
this.mccbSelectTheme.EditorControl.Rows.Add("Black", "Office2010Black");
this.mccbSelectTheme.SelectedIndex = 0;
//enable event
this.mccbSelectTheme.SelectedValueChanged += this.mccbSelectTheme_SelectedValueChanged;
}
private void mccbSelectTheme_SelectedValueChanged(object sender, EventArgs e)
{
string cc = mccbSelectTheme.EditorControl.CurrentRow.Cells[1].Value.ToString();
ThemeResolutionService.ApplicationThemeName = cc;
}
I changed my code to mimic yours using a DataTable, but have the same results. I can click the control with no problem. Only occurs if I click on the dropdown arrow. AS soon as I click on the arrow it errors out. Box does not drop down.'
private void frmSettings_Load(object sender, EventArgs e)
{
ThemeResolutionService.ApplicationThemeName = "Desert";
//disable event
this.mccbSelectTheme.SelectedValueChanged -= this.mccbSelectTheme_SelectedValueChanged;
DataTable dtThemes = new DataTable();
dtThemes.Columns.Add("Name", typeof(string));
dtThemes.Columns.Add("ThemeName", typeof(string));
dtThemes.Rows.Add("Aqua", "Aqua");
dtThemes.Rows.Add("Breeze", "Breeze");
dtThemes.Rows.Add("Desert", "Desert");
dtThemes.Rows.Add("Fluent", "Fluent");
dtThemes.Rows.Add("Fluent Dark", "FluentDark");
dtThemes.Rows.Add("Black", "Office2010Black");
this.mccbSelectTheme.DataSource = dtThemes; ;
this.mccbSelectTheme.Columns[1].IsVisible = false;
this.mccbSelectTheme.SelectedIndex = 0;
this.mccbSelectTheme.EditorControl.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
//enable event
this.mccbSelectTheme.SelectedValueChanged += this.mccbSelectTheme_SelectedValueChanged;
}
private void mccbSelectTheme_SelectedValueChanged(object sender, EventArgs e)
{
ThemeResolutionService.ApplicationThemeName = mccbSelectTheme.EditorControl.CurrentRow.Cells[1].Value.ToString(); ;
}
This is a simple app that shows the problem. DropBox link attached.
https://www.dropbox.com/t/7v6Jvn0WX342PXDJ
Hello, Claude,
The provided modified project is greatly appreciated. I was able to run it locally however I did not reproduce the error on my end when clicking the drop-down arrow. Please refer to the attached gif file that demonstrates the result. From the provided code snippet I see that you use ThemeResolutionService.ApplicationThemeName = "Desert" and change it accordingly in the project. Still, the error does not reproduce.
Could you share more information about the error that you get, a stack trace would be greatly appreciated? Which Telerik version you use in your project?
I am looking forward to your reply.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Thank you for your reply. I am using the latest version, framework 4.7.2
Here is the call stack
>TelerikWinFormsApp8.exe!TelerikWinFormsApp8.RadForm1.RadMultiColumnComboBox1_SelectedValueChanged(object sender, System.EventArgs e) Line 44C#
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadMultiColumnComboBox.OnSelectedValueChanged(System.EventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadMultiColumnComboBox.comboBoxElement_SelectedValueChanged(object sender, System.EventArgs e)Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.BaseComboBoxElement.OnSelectedValueChanged(System.EventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadMultiColumnComboBoxElement.FireSelectionEvents(Telerik.WinControls.UI.CurrentRowChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadMultiColumnComboBoxElement.OnGrid_CurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadGridView.OnCurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.EventDispatcher.RaiseEvent<Telerik.WinControls.UI.CurrentRowChangedEventArgs>(object eventKey, object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs args)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.ChangeCurrentRow(Telerik.WinControls.UI.GridViewRowInfo oldRow, Telerik.WinControls.UI.GridViewRowInfo row, Telerik.WinControls.UI.GridViewTemplate viewTemplate)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.SetPositionCore(Telerik.WinControls.UI.GridViewRowInfo newRow, Telerik.WinControls.UI.GridViewColumn newColumn, Telerik.WinControls.UI.GridViewRowInfo oldRow, Telerik.WinControls.UI.GridViewColumn oldColumn, bool validateRowChange)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.SetPosition(Telerik.WinControls.UI.GridViewRowInfo row, Telerik.WinControls.UI.GridViewColumn column, bool validateRowChange)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.ProcessCurrentChanged(Telerik.WinControls.UI.GridViewEvent eventData)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.ProcessEventCore(Telerik.WinControls.UI.GridViewEvent eventData)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewTemplate.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(Telerik.WinControls.UI.GridViewEvent eventData)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(Telerik.WinControls.UI.GridViewEvent gridEvent, Telerik.WinControls.UI.PriorityWeakReferenceList list, Telerik.WinControls.UI.GridEventProcessMode processMode)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(Telerik.WinControls.UI.GridViewEvent gridEvent)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(Telerik.WinControls.UI.GridViewEvent gridEvent)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(Telerik.WinControls.UI.GridViewTemplate template, Telerik.WinControls.UI.GridViewRowInfo row, Telerik.WinControls.UI.GridViewColumn column, bool user)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.CurrentRow.set(Telerik.WinControls.UI.GridViewRowInfo value)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadGridView.CurrentRow.set(Telerik.WinControls.UI.GridViewRowInfo value)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MultiColumnComboPopupForm.Rows_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewRowCollection.OnCollectionChanged(Telerik.WinControls.Data.NotifyCollectionChangedEventArgs args)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewRowCollection.ListSource_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)Unknown
Telerik.WinControls.dll!Telerik.WinControls.Data.RadListSource<System.__Canon>.OnCollectionChanged(Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)Unknown
Telerik.WinControls.dll!Telerik.WinControls.Data.RadListSource<System.__Canon>.EndUpdate(bool notifyUpdates)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewTemplate.EndUpdate(bool notify, Telerik.WinControls.UI.DataViewChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MasterGridViewTemplate.EndUpdate(bool notify, Telerik.WinControls.UI.DataViewChangedEventArgs e)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.GridViewTemplate.EndUpdate()Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.RadGridViewElement.DpiScaleChanged(System.Drawing.SizeF scaleFactor)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.DpiScaleChanged(System.Drawing.SizeF scaleFactor)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RootRadElement.DpiScaleChanged(System.Drawing.SizeF scaleFactor)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadControl.ScaleControl(System.Drawing.SizeF factor, System.Windows.Forms.BoundsSpecified specified)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ScaleControl(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.Scale(System.Drawing.SizeF factor)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.Scale(System.Drawing.SizeF factor)Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadPopupControlBase.ShowPopupCore(System.Drawing.Size size, System.Drawing.Point location)Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadPopupControlBase.ShowPopup(System.Drawing.Rectangle alignmentRectangle)Unknown
Telerik.WinControls.GridView.dll!Telerik.WinControls.UI.MultiColumnComboPopupForm.ShowPopup(System.Drawing.Rectangle alignmentRectangle)Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.PopupEditorBaseElement.ShowPopup()Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.BaseComboBoxElement.ShowPopup()Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.BaseComboBoxElement.OnBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.RaiseBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadItem.RaiseBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.RaiseBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.RaiseBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadItem.RaiseBubbleEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.RaiseRoutedEvent(Telerik.WinControls.RadElement sender, Telerik.WinControls.RoutedEventArgs args)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadElement.DoMouseUp(System.Windows.Forms.MouseEventArgs e)Unknown
Telerik.WinControls.dll!Telerik.WinControls.ComponentInputBehavior.OnMouseUp(System.Windows.Forms.MouseEventArgs e)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadControl.OnMouseUp(System.Windows.Forms.MouseEventArgs e)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)Unknown
System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m)Unknown
Telerik.WinControls.dll!Telerik.WinControls.RadControl.WndProc(ref System.Windows.Forms.Message m)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)Unknown
TelerikWinFormsApp8.exe!TelerikWinFormsApp8.Program.Main() Line 17C#
Hello, Claude,
Thank you for providing the call stack. According to it, it seems that the problem is the 44th line of your form in TelerikWinFormsApp8.exe. I suppose that this is the same project you provided earlier.
I am using the latest 2020.3.1020 version and does not receive the error that you had. I recorded a small video demonstrating the result on my end. Am I missing something? Do I need to do anything else to reproduce the error when clicking on the arrow button? In order to inspect what causes the error, it is important to reproduce it locally. Thank you in advance for your understanding and cooperation.
I am looking forward to your reply.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello, Claude,
According to the exception that you get, it seems that the CurrentRow in EditorControl is null on your end. It becomes null when there is no current row in the grid. I could suggest adding an if-clause and check if the CurrentRow is not null before accessing its Cells collection.
private void RadMultiColumnComboBox1_SelectedValueChanged(object sender, EventArgs e)
{
if (this.radMultiColumnComboBox1.EditorControl.CurrentRow != null)
{
string cc = radMultiColumnComboBox1.EditorControl.CurrentRow.Cells[1].Value.ToString();
}
}
There is a CurrentRowChanged event as well. You can use it if you want to track every time when the current row has changed.
The current row becomes null if you enter a text into the text box filed and press the Enter key. In this case, if there is no such result in the drop-down list the current row will be null. In this case, I would suggest setting DropDownStyle to DropDownList. Thus, the text box are could not be edited. However, you mentioned that you receive the error when clicking on the dropdown. Can you give these suggestions a try and let me know how they work for you?
I am looking forward to your reply.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
We get the same result as Claude only when it is run in 125% DPI. We are using 2021.1.122.40.
Hi, Paul,
I am sorry to hear that you are experiencing any undesired behavior with RadMultiColumnComboBox. However, the provided information is not enough for me to replicate the issue locally and investigate further the precise case. I would recommend you to submit a support ticket from your Telerik account and provide detailed information about the precise case.
A sample project, demonstrating the exact undesired behavior that you are facing, may save a lot of days and efforts on both sides. That is why it is always greatly appreciated if you simulate the problematic behavior in a runnable project. Then, we would be able to make an adequate analysis of the precise case and think about a suitable solution. This is the most important thing you can do to clearly demonstrate your issue. Replicating your issue is no doubt the most time consuming part, but it's going to play the biggest role in your success at demonstrating your issue clearly the first time. It often feels easier to copy and paste the relevant portions of your code into the ticket. The problem with this approach is that the pieces have to be reviewed by somebody who doesn't know what the entire project is supposed to look like or accomplish.
Thank you in advance for your cooperation.