Data Binding with BindingSource
Hi,
I'm using a GridDataBoundGrid. I have been using it for some time successfully with a filtering row enabled.
Today I wanted to switch to using a BindingSource instead of setting a collection directly on the grid's DataSource property. However, this has brought about two problems:
1. The filter row has disappeared.
2. The second time the BindingSource.DataSource property is set I get an exception:
System.ArgumentException: DuplicateMappingName
Parameter name: column
at Syncfusion.Windows.Forms.Grid.GridBoundColumnsCollection.CheckForMappingNameDuplicates(GridBoundColumn column)
at Syncfusion.Windows.Forms.Grid.GridBoundColumnsCollection.Add(GridBoundColumn column)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.bindingList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
at System.Windows.Forms.BindingSource.ResetList()
at System.Windows.Forms.BindingSource.set_DataSource(Object value)
Any help appreciated.
I'm using a GridDataBoundGrid. I have been using it for some time successfully with a filtering row enabled.
Today I wanted to switch to using a BindingSource instead of setting a collection directly on the grid's DataSource property. However, this has brought about two problems:
1. The filter row has disappeared.
2. The second time the BindingSource.DataSource property is set I get an exception:
System.ArgumentException: DuplicateMappingName
Parameter name: column
at Syncfusion.Windows.Forms.Grid.GridBoundColumnsCollection.CheckForMappingNameDuplicates(GridBoundColumn column)
at Syncfusion.Windows.Forms.Grid.GridBoundColumnsCollection.Add(GridBoundColumn column)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.bindingList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
at System.Windows.Forms.BindingSource.ResetList()
at System.Windows.Forms.BindingSource.set_DataSource(Object value)
Any help appreciated.
SIGN IN To post a reply.
6 Replies
HA
haneefm
Syncfusion Team
October 15, 2007 07:49 PM UTC
Hi Lcd,
1. The filter row has disappeared.
>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer the following forum and let me know if you are looking something different
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=43418
2. The second time the BindingSource.DataSource property is set I get an exception:
>>>>>>>>>>>>>>>>>>>>>>>>>
Try calling the InternalColumns.Clear() method before restting the underlying datasource of the grid. Here is a code snippet.
this.gridDataBoundGrid.Binder.InternalColumns.Clear();
this.gridDataBoundGrid.DataSource = newBindingList;
Best Regards,
Haneef
1. The filter row has disappeared.
>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer the following forum and let me know if you are looking something different
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=43418
2. The second time the BindingSource.DataSource property is set I get an exception:
>>>>>>>>>>>>>>>>>>>>>>>>>
Try calling the InternalColumns.Clear() method before restting the underlying datasource of the grid. Here is a code snippet.
this.gridDataBoundGrid.Binder.InternalColumns.Clear();
this.gridDataBoundGrid.DataSource = newBindingList;
Best Regards,
Haneef
LC
lcd
October 16, 2007 11:01 AM UTC
Hmm, I need to take a different approach if filtering isn't supported with the BindingSource.
Is it possible to have a column that isn't visible? That way I can apply a filter to that column (instead of applying a filter to the BindingSource). I don't want the user to see the column but I do want to be able to filter on it behind the scenes. I can't see any way to hide a column in the grid.
Thanks
>Hi Lcd,
1. The filter row has disappeared.
>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer the following forum and let me know if you are looking something different
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=43418
2. The second time the BindingSource.DataSource property is set I get an exception:
>>>>>>>>>>>>>>>>>>>>>>>>>
Try calling the InternalColumns.Clear() method before restting the underlying datasource of the grid. Here is a code snippet.
this.gridDataBoundGrid.Binder.InternalColumns.Clear();
this.gridDataBoundGrid.DataSource = newBindingList;
Best Regards,
Haneef
Is it possible to have a column that isn't visible? That way I can apply a filter to that column (instead of applying a filter to the BindingSource). I don't want the user to see the column but I do want to be able to filter on it behind the scenes. I can't see any way to hide a column in the grid.
Thanks
>Hi Lcd,
1. The filter row has disappeared.
>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer the following forum and let me know if you are looking something different
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=43418
2. The second time the BindingSource.DataSource property is set I get an exception:
>>>>>>>>>>>>>>>>>>>>>>>>>
Try calling the InternalColumns.Clear() method before restting the underlying datasource of the grid. Here is a code snippet.
this.gridDataBoundGrid.Binder.InternalColumns.Clear();
this.gridDataBoundGrid.DataSource = newBindingList;
Best Regards,
Haneef
HA
haneefm
Syncfusion Team
October 16, 2007 05:51 PM UTC
Hi Lcd,
Use the GridDataBoundGrid.Model.Cols.Hidden property to hide/show the column in a Grid. Please try this code
this.gridDataBoundGrid1.Model.Cols.Hidden[2] = true; //C#
Me.GridDataBoundGrid.Model.Cols.Hidden(2) = True ' VB
Best regards,
Haneef
Use the GridDataBoundGrid.Model.Cols.Hidden property to hide/show the column in a Grid. Please try this code
this.gridDataBoundGrid1.Model.Cols.Hidden[2] = true; //C#
Me.GridDataBoundGrid.Model.Cols.Hidden(2) = True ' VB
Best regards,
Haneef
LC
lcd
October 18, 2007 10:01 AM UTC
Thanks Haneef, that worked OK.
One final question (I hope): how do I programmatically alter the filter applied to a column? I have access to both the grid and the filter bar, but can't see anything obvious to do this.
Thanks
One final question (I hope): how do I programmatically alter the filter applied to a column? I have access to both the grid and the filter bar, but can't see anything obvious to do this.
Thanks
LC
lcd
October 18, 2007 10:27 AM UTC
PS. I see there's a GridFilterBar.RowFilter property, but using that would mean I have to manually add/remove the filter for the particular column. Is there a way I can apply/remove a filter against a column and have the RowFilter automatically managed for me?
Thanks
Thanks
HA
haneefm
Syncfusion Team
October 27, 2007 12:13 AM UTC
Hi lcd,
One way you can control GridFilterBar.RowFilter property of the GridFilterbar to derive the GridFilterbar and override the GetFilterFromRow method. Below is a minimal sample that shows "How to filter the combobox column using the display member?".
Sample : ForumFilterBarDisplayMember.zip
Thanks for choosing and using Syncfusion Products.
Best Regards,
Haneef
One way you can control GridFilterBar.RowFilter property of the GridFilterbar to derive the GridFilterbar and override the GetFilterFromRow method. Below is a minimal sample that shows "How to filter the combobox column using the display member?".
Sample : ForumFilterBarDisplayMember.zip
Thanks for choosing and using Syncfusion Products.
Best Regards,
Haneef
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
LC lcd
- Oct 15, 2007 03:48 PM UTC
- Oct 27, 2007 12:13 AM UTC