Question how to set a new bindingsource to a datagridview?

evolet10000

Active member
Joined
Nov 22, 2012
Messages
40
Programming Experience
Beginner
OK, I have 2 bounded datagridviews in my form naming beneficiarydatagridview and beneficiarydatagridview1 which is bound to the same bindingsource... now heres the thing in my beneficiarydatagridview i have a search engine using textbox and a button, using the .FILTER feature of bindingsource...its working properly ,it shows the exact data...on my 1st datagrid(beneficiarydatagridview)... but since my 2nd datagrid(beneficiarydatagridview1) is also bounded to the same bindingsource it also displays the same data...now how can i avoid my 2nd datagrid(beneficiarydatagridview1) not to change its value? whenever i execute a search in my 1st datagrid?

i tried to declare a new bindingsource but still the same occurs...heres my code

Dim mybinding19 As New BindingSource
mybinding19.DataSource = Me.SPESDataSet.BENEFICIARIES
BENEFICIARIESDataGridView1.DataSource = mybinding19

thanks for your kindness in advance :D
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,171
Location
Sydney, Australia
Programming Experience
10+
Using two BindingSources will allow you to make separate selections in the two grids but it won't let you filter or sort independently because it's still the same DataView underneath and it's that DataView that actually does the sorting and filtering. If you want to filter and/or sort independently then you need two different DataViews, e.g.
Dim view1 As New DataView(myDataTable)
Dim view2 As New DataView(myDataTable)

BindingSource1.DataSource = view1
DataGridView1.DataSource = BindingSource1

BindingSource2.DataSource = view2
DataGridView2.DataSource = BindingSource2
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,334
Location
Norway
Programming Experience
10+
Binding to a DataSet and specifying table name in DataMember will also create different a DataView for same table on multiple bindingsources.
 

evolet10000

Active member
Joined
Nov 22, 2012
Messages
40
Programming Experience
Beginner
That solves the problem :D works like a charm... thanks Moderators :D
 
Top Bottom