This is a migrated thread and some comments may be shown as answers.

gridview combobox filter on combo box columns

3 Answers 264 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nadav
Top achievements
Rank 1
Nadav asked on 22 May 2010, 12:55 PM
Hi,
I have a column that is connected to an enum, and another column that is connected to a list of objects.
when i try to select an object/enum member on the filter, the system crashes.
in the enum case with the following reason:

System.InvalidCastException was unhandled
  Message="Invalid cast from 'System.String' to 'Sivan3.Dao.Poco.Student+StudentStatus'."
  Source="mscorlib"
  StackTrace:
       at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
       at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at Telerik.WinControls.UI.GridFilterCellElement.SetFilterValue(Object value)
       at Telerik.WinControls.UI.GridFilterCellElement.set_Value(Object value)
       at Telerik.WinControls.UI.RadGridView.UpdateFiltering()
       at Telerik.WinControls.UI.RadGridView.OnValueChanged(Object sender, EventArgs e)
       at Telerik.WinControls.UI.RadGridView.CallValueChanged(Object sender, EventArgs e)
       at Telerik.WinControls.UI.BaseGridEditor.OnValueChanged()
       at Telerik.WinControls.UI.RadComboBoxEditor.comboBoxElement_TextChanged(Object sender, EventArgs e)
       at Telerik.WinControls.RadItem.OnTextChanged(EventArgs e)
       at Telerik.WinControls.UI.EditorBaseElement.OnTextChanged(EventArgs e)
       at Telerik.WinControls.RadItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
       at Telerik.WinControls.UI.PopupEditorBaseElement.OnPropertyChanged(RadPropertyChangedEventArgs e)
       at Telerik.WinControls.UI.RadComboBoxElement.OnPropertyChanged(RadPropertyChangedEventArgs e)
       at Telerik.WinControls.RadObject.RaisePropertyNotifications(RadPropertyValue propVal, Object oldValue, Object newValue, ValueSource oldSource)
       at Telerik.WinControls.RadObject.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source)
       at Telerik.WinControls.RadElement.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source)
       at Telerik.WinControls.RadObject.SetValue(RadProperty property, Object value)
       at Telerik.WinControls.RadItem.set_Text(String value)
       at Telerik.WinControls.UI.RadComboBoxElement.set_Text(String value)
       at Telerik.WinControls.UI.RadComboBoxElement.SyncTextWithItem()
       at Telerik.WinControls.UI.ComboPopupForm.listBoxElement_SelectedIndexChanged(Object sender, EventArgs e)
       at Telerik.WinControls.UI.RadListBoxElement.OnSelectedIndexChanged(SelectedIndexChangedEventArgs e)
       at Telerik.WinControls.UI.RadListBoxElement.DispatchSelectionEvents(Boolean selectedIndex, Boolean selectedItem, Object oldValue)
       at Telerik.WinControls.UI.RadListBoxElement.SetSelectedIndex(Int32 value, Boolean fireEvents)
       at Telerik.WinControls.UI.RadListBoxElement.set_SelectedIndex(Int32 value)
       at Telerik.WinControls.UI.RadListBoxElement.HandleSelectOne(Int32 newIndex)
       at Telerik.WinControls.UI.RadListBoxElement.ProcessSelection(Int32 newIndex, Boolean onMouseDrag, InputDevice device)
       at Telerik.WinControls.UI.RadListBoxElement.ProcessMouseSelection(RadItem item, MouseNotification reason)
       at Telerik.WinControls.UI.RadListBoxItem.DispatchMouseNotification(MouseNotification notification)
       at Telerik.WinControls.UI.RadListBoxItem.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
       at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e)
       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
       at Telerik.WinControls.UI.ComboPopupForm.WndProc(Message& msg)
       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 Sivan3.Program.Main() in D:\Sivan3\trunk\src\PC\Sivan3\Program.cs:line 32
       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()
  InnerException: 

on the databound columns, it throws an exception that an Object Must implement IConvertible.

Thanks,
Nadav Ben-Gal

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 27 May 2010, 07:50 AM
Hello Nadav,

You can find the answer to your question in the support ticket that you have opened concerning the same topic.

Regards,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vivek
Top achievements
Rank 1
answered on 29 Aug 2012, 06:17 AM
hi this is vivek 

currently am using telerik winforms demo ver q2 2012 . is there any possible for telerik rad grid view filter textbox to combobox .
i want use filter textbox column to combobox .
0
Svett
Telerik team
answered on 03 Sep 2012, 07:47 AM
Hi Vivek,

You can replace the text box editor with drop down list editor by using the EditorRequired and CellEditorInidialized events. You can use the following code snippets as sample:
void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)
    {
        if (e.EditorType == typeof(RadTextBoxEditor))
        {
            e.EditorType = typeof(RadDropDownListEditor);
        }
    }
}
 
 
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (e.Row is GridViewFilteringRowInfo)
    {
        RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
        RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
        element.DisplayMember = "DisplayMember";
        element.ValueMember = "ValueMember";
        element.DataSource = source;
    }
}

I hope this helps.
 
Regards,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Nadav
Top achievements
Rank 1
Answers by
Svett
Telerik team
Vivek
Top achievements
Rank 1
Share this question
or