dcsimg
Results 1 to 10 of 10

Thread: [RESOLVED] msflexgrid populating question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Resolved [RESOLVED] msflexgrid populating question

    I wanted to ask how to do this problem.

    I have this form A with msflexgrid A with no records. then I have
    another form B with msflexgrid B with 10 rows of record.

    I need to copy the records from grid B to grid A.
    How should this be done?

  2. #2
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: msflexgrid populating question

    CodeSearcher

    In general terms,
    .. 1. assure GridA has same number of rows
    .. 2. assure GridA has same number of cols
    .. 3. use a nested loop to copy each cell


    Code:
    With FormA.GridA
        .Rows = FormB.GridB.Rows
        .Cols = FormB.GridB.Cols
        For rr = 0 To FormB.GridB.Rows - 1
            For cc = 0 To FormB.GridB.Cols - 1
                .TextMatrix(rr, cc) = FormB.GridB.TextMatrix(rr, cc)
            Next cc
        Next rr
    End With
    I did not test this, but perhaps something along these lines may do the trick

    Spoo

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,094

    Re: msflexgrid populating question

    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,283

    Re: msflexgrid populating question

    Spoo...your (tested) code works just fine....

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,094

    Re: msflexgrid populating question

    Just out of curiosity: i was just thinking along the same line as spoo, but using copymemory with the strptr-function. Any ideas on performance?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,329

    Re: msflexgrid populating question

    If the memory is not contiguous (ie: you need to do it one cell at a time), I would expect the performance to be slightly worse.

    There is a variation of Spoo's method that might be quicker, using the Clip property:
    Code:
    With FormA.GridA
        .Rows = FormB.GridB.Rows
        .Cols = FormB.GridB.Cols
    
        .Row = 0
        .Col = 0
        .RowSel = .Rows -1
        .ColSel = .Cols - 1
        .Clip = FormB.GridB.Clip
    
    End With
    edit: oops, I should have checked the link in post #3 first! ah well, at least I've given an example of what was mentioned there!

  7. #7
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: msflexgrid populating question

    Zvoni and Si

    Clip is a new one on me. Nice to know about.

    My code snippet was a prelude to further code ,, mainly to set col widths to match.
    Does Clip automatically do that?

    Spoo

  8. #8
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: msflexgrid populating question

    Sam

    Thanks for the good news ..

    Spoo

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,329

    Re: msflexgrid populating question

    Quote Originally Posted by Spoo View Post
    My code snippet was a prelude to further code ,, mainly to set col widths to match.
    Good idea... then there is also unfortunately the issue of cell formatting etc, but I think it's best for the OP to do the bits that matter to them.

    Does Clip automatically do that?
    I'm afraid not, it is just a way to copy/paste the text... if you want, you can use ClipBoard.SetText grid.Clip , then manually paste directly into Excel etc.

  10. #10
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: msflexgrid populating question

    Si

    Thanks for the info.
    Yes, little steps at a time. Will wait for OP's reply.

    Spoo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width