parent child grandchild grids

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Fagen

    #1

    parent child grandchild grids

    Hi,

    I wondering if someone can explain the best way to show three datagrids
    in a parent/child/grandchild relationship?

    For example:
    Take a simple form with 3 datagrids - the top for the customers, the
    middle for the orders, and the bottom for the items of the order.

    I'd like to know the best why to update the grids so that when the user
    changes the current row in the customers' grid, only that customer's
    orders are displayed in the middle orders grid. At the same time, I'd
    like the bottom items' grid to display only the rows belonging to the
    currently selected order in the middle grid.

    I've been doing this for years in other languages (mostly DOS based
    xBase languages) but I am new to doing this in VB.

    Can anyone get me started?

    Richard


  • Cor Ligthert

    #2
    Re: parent child grandchild grids

    Richard,

    There is no best way.

    I myself go mostly for the situation when it are comboboxes to create
    dependable dataviews.

    This I did not with a datagrid however it should be possible when you use
    the currencymanager (I never did it this way)

    Datagrid 1 is a full datagrid of all

    Datagrid 2 is a datagrid, that has a dataview with rowfilter depending on a
    column on the current position of datagrid1 (you need the currencymanager
    for that, that is not about money what a lot of people think at the start)

    http://msdn.microsoft.com/library/de...classtopic.asp

    Datagrid 3 is a datagrid, that has the same based on Datagrid2

    It needs to much code (sample datatables) to make a simple sample for this.

    You can however as well go for the datarelation way.

    http://msdn.microsoft.com/library/de...tionstopic.asp

    As I said before I never did this kind of things with 3 deep except with the
    combobox and than I have again another approach.

    I hope thst this gives some ideas.

    Cor


    Comment

    • Richard Fagen

      #3
      Re: parent child grandchild grids

      Hi Cor,

      I have started experimenting with the CurrencyManager and the DataView
      and they seem to be exactly what I need.

      My question is where should I declare them?

      I would like to be able to access Dataviews and rowfilters from an event
      and I don't know who to give them proper scope.

      I tried to declare them at the top of the form but I was having trouble
      with the data adapters.

      Where is the best place to declare the following (top of form, code
      module, form load event?)
      - sqlconnections
      - data adapters
      - data sets
      - relations
      - dataviews

      You have definitely given me many ideas to try out, thanks!

      Richard



      Cor Ligthert wrote:[color=blue]
      > Richard,
      >
      > There is no best way.
      >
      > I myself go mostly for the situation when it are comboboxes to create
      > dependable dataviews.
      >
      > This I did not with a datagrid however it should be possible when you use
      > the currencymanager (I never did it this way)
      >
      > Datagrid 1 is a full datagrid of all
      >
      > Datagrid 2 is a datagrid, that has a dataview with rowfilter depending on a
      > column on the current position of datagrid1 (you need the currencymanager
      > for that, that is not about money what a lot of people think at the start)
      >
      > http://msdn.microsoft.com/library/de...classtopic.asp
      >
      > Datagrid 3 is a datagrid, that has the same based on Datagrid2
      >
      > It needs to much code (sample datatables) to make a simple sample for this.
      >
      > You can however as well go for the datarelation way.
      >
      > http://msdn.microsoft.com/library/de...tionstopic.asp
      >
      > As I said before I never did this kind of things with 3 deep except with the
      > combobox and than I have again another approach.
      >
      > I hope thst this gives some ideas.
      >
      > Cor
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: parent child grandchild grids

        Richard,

        I would not worry to much at this moment about what you ask now.

        datagrid1.datas ource = dataview1

        than
        directcast(data grid1.datasourc e,dataview).tab le (gives you your original
        table
        than
        directcast(data grid1.datasourc e,dataview) gives you your used dataview
        (depend of you instanced it with new, otherwise is that the
        datatable.defau ltview

        However don't worry first try to understand those other things in my opinion
        and make your program running. Optimizing comes when you understand what you
        are doing.

        The rule is that when you can declare/instance something as low as possible
        in a method you would have to do that. (Gives beside better reading a better
        performance of the GC).

        What gives:
        (Load event) is as every method
        Top of form is global for the class
        Module is global for your application.

        As exacmple
        Not
        Dim i as integer,
        for i = 0 to end
        however
        for i as integer = 0 to end

        And only when this is not possible than every time a level higher (by
        instance in this sample when you exit the for loop and need that "i" because
        that was the last one)

        I hope this helps,

        Cor


        Comment

        • Richard Fagen

          #5
          Re: parent child grandchild grids

          Hi Cor,

          Thanks for your help. I almost got it the way I want. I need to do
          more testing.


          Richard

          p.s. thanks for the idea about directcast, I never even heard of that
          command :)

          Cor Ligthert wrote:[color=blue]
          > Richard,
          >
          > I would not worry to much at this moment about what you ask now.
          >
          > datagrid1.datas ource = dataview1
          >
          > than
          > directcast(data grid1.datasourc e,dataview).tab le (gives you your original
          > table
          > than
          > directcast(data grid1.datasourc e,dataview) gives you your used dataview
          > (depend of you instanced it with new, otherwise is that the
          > datatable.defau ltview
          >
          > However don't worry first try to understand those other things in my opinion
          > and make your program running. Optimizing comes when you understand what you
          > are doing.
          >
          > The rule is that when you can declare/instance something as low as possible
          > in a method you would have to do that. (Gives beside better reading a better
          > performance of the GC).
          >
          > What gives:
          > (Load event) is as every method
          > Top of form is global for the class
          > Module is global for your application.
          >
          > As exacmple
          > Not
          > Dim i as integer,
          > for i = 0 to end
          > however
          > for i as integer = 0 to end
          >
          > And only when this is not possible than every time a level higher (by
          > instance in this sample when you exit the for loop and need that "i" because
          > that was the last one)
          >
          > I hope this helps,
          >
          > Cor[/color]

          Comment

          Working...