|
-
Apr 19th, 2007, 06:19 AM
#1
Thread Starter
Hyperactive Member
Button Captions from Flexgrid
Hi All
I am really struggeling with something simple, i have a vsflexgrid with 1 col and 10 rows i then have an array of 10 command buttons cmdDep and i just can't seem to figure out how to get the names from each row in the grid to populate all 10 button captions. I did the same thing a while back with populating the captions from a database and that was no problem, but i can't seem to get my head around looping through the grid and the command buttons. Please could someone shed some light on this for me.
Many thanks in advance
-
Apr 19th, 2007, 06:37 AM
#2
Fanatic Member
Re: Button Captions from Flexgrid
With MSFlexGrid1
For i = 1 to .Rows - 1 'assuming you have a fixed header row
cmdDep(i).Caption = .TextMatrix(i,0)
Next
End With
-
Apr 19th, 2007, 06:37 AM
#3
Re: Button Captions from Flexgrid
Try this:
vb Code:
Private Sub GetButtonNames()
Dim i As Long
For i = 0 To 9
cmdDep(i).Caption = MSFlexGrid1.TextMatrix(i, 0)
Next
End Sub
Edit: I assumed you have no fixed headers.
-
Apr 19th, 2007, 06:57 AM
#4
Thread Starter
Hyperactive Member
Re: Button Captions from Flexgrid
Thank you so much guys, i knew i was missing something so simple, another question on the same topic, that i have been thinking about, i have 10 command buttons cmdDep and in my grid i have say 30 rows, so when the form loads it populates the captions from the first 10 rows of the grid, i have added a button cmdDown when clicked it must populate the captions with the next 10 rows from the grid and if clicked again populate from the next 10 rows. Any ideas on how i would be able to do this.
Many thanks
-
Apr 19th, 2007, 08:05 AM
#5
Fanatic Member
Re: Button Captions from Flexgrid
Just store a variable containing the 'latest last number' of the rows you have used.
Private LastRow as Byte
Let's say in Form_Activate() you run the code that sets the captions using row 0 to row 9 ... at this point you would do this:
LastRow = 9
Then when you click the button you would use
For i = LastRow + 1 To LastRow + 11
cmdDep(i - (LastRow + 1)).Caption = MSFlexGrid1.TextMatrix(i,0)
Next
-
Apr 19th, 2007, 10:35 AM
#6
Re: Button Captions from Flexgrid
 Originally Posted by Webskater
With MSFlexGrid1
For i = 1 to .Rows - 1 'assuming you have a fixed header row
Don't.
Code:
For i = .FixedRows to .Rows - 1
.FixedCols accounts for fixed columns.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Apr 20th, 2007, 02:17 AM
#7
Thread Starter
Hyperactive Member
Re: Button Captions from Flexgrid
Thanks guys.
All sorted and working great.
Many thanks once again
-
May 21st, 2007, 10:48 AM
#8
Junior Member
Re: Button Captions from Flexgrid
 Originally Posted by alexanderjames
Hi All
I am really struggeling with something simple, i have a vsflexgrid with 1 col and 10 rows i then have an array of 10 command buttons cmdDep and i just can't seem to figure out how to get the names from each row in the grid to populate all 10 button captions. I did the same thing a while back with populating the captions from a database and that was no problem, but i can't seem to get my head around looping through the grid and the command buttons. Please could someone shed some light on this for me.
Many thanks in advance
How did you put command buttons into the vsFlexgrid?
-
May 21st, 2007, 02:19 PM
#9
Re: Button Captions from Flexgrid
@dtrade,
Similar to this way.
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
|