• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 563
  • Last Modified:

Filtering / Binding Datagridview objects

Hi Experts - I have a windows form that I added some textboxes to from a table (called Master) and VS automatically created the MasterBindingSource, MasterTableAdapter, MasterBindingNavigation etc.... All of this works ok and I can scroll throught the data using the navigation buttons.

Next I want to add a 'subform' as I know it from my MS Access days - I've used a Datagridview and all works ok except it shows all the data in the datagridview not just the data pertaining to the current record on my Master table.

I've attempted filtering the datagridview using code - and it sort of works, but I have it triggering on the navigation buttons and therefore the event triggers before the page updates and therefore the datagrid is always showing the prior records data.

Am I missing a more simple solution and if not when/where should I run the filtering code?

Thanks,

Sam
0
SamB
Asked:
SamB
  • 2
  • 2
2 Solutions
 
Jorge PaulinoIT Pro/DeveloperCommented:
>> Am I missing a more simple solution and if not when/where should I run the filtering code?

Try on the Datagridview selection change event
0
 
SamBAuthor Commented:
Hi jpaulino,

Just tried the datagridview selectionchange event - initially it doesn't work because it seems to fire this event before the page is populated with data and therefore my filtering expression has an empty textbox that it doesn't like.

I can get over that by coding a default value to the textbox (although would prefer not to) but even when I do the datagridview only updates to the correct data when I change something in it - not when I move between records on the form.

Thanks,

Sam
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Cna you show us your code ?
0
 
SanclerCommented:
.RowEnter?

On the firing with an empty textbox, how about enclosing the relevant code in a test for the textbox being empty?

Roger
0
 
SamBAuthor Commented:
Hi Guys, thanks for your advise - I used a bit of both to get it going so spread the points between you.

Cheers,

Sam
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now