-
Jul 16th, 2013, 08:53 AM
#1
Thread Starter
Frenzied Member
[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?
-
Jul 16th, 2013, 09:19 AM
#2
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
-
Jul 16th, 2013, 09:27 AM
#3
Re: msflexgrid populating question
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE 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.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Jul 16th, 2013, 12:40 PM
#4
Re: msflexgrid populating question
Spoo...your (tested) code works just fine....
-
Jul 16th, 2013, 12:54 PM
#5
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?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE 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.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Jul 16th, 2013, 01:15 PM
#6
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!
-
Jul 16th, 2013, 02:25 PM
#7
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
-
Jul 16th, 2013, 02:28 PM
#8
Re: msflexgrid populating question
Sam
Thanks for the good news ..
Spoo
-
Jul 16th, 2013, 02:41 PM
#9
Re: msflexgrid populating question
Originally Posted by Spoo
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.
-
Jul 16th, 2013, 05:08 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|