We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Data Binding with BindingSource

Thread ID:

Created:

Updated:

Platform:

Replies:

69110 Oct 15,2007 11:48 AM Oct 26,2007 08:13 PM Windows Forms 6
loading
Tags: GridControl
lcd
Asked On October 15, 2007 11:48 AM

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.

haneefm [Syncfusion]
Replied On October 15, 2007 03:49 PM

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

lcd
Replied On October 16, 2007 07:01 AM

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

haneefm [Syncfusion]
Replied On October 16, 2007 01:51 PM

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

lcd
Replied On October 18, 2007 06:01 AM

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

lcd
Replied On October 18, 2007 06:27 AM

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

haneefm [Syncfusion]
Replied On October 26, 2007 08:13 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;