Link to home
Start Free TrialLog in
Avatar of mattjulius
mattjulius

asked on

Put image to Flexgrid

Just wanna ask how can I put an image to flexgrid.
example:
I have add, delete, edit button (serve as button) and the flex grid has 10 data from my database, what I want to do is to loop    these images according to the data from dbase.So, If I have 10 records all of them has these buttons...
Avatar of Shiju S
Shiju S
Flag of United States of America image

try this

Private Sub Command1_Click()
    SetFlexPic 1, 1, "C:\pic.ico"
End Sub

Private Sub SetFlexPic(row As Integer, col As Integer, PicturePath As String)
    MSFlexGrid1.row = row
    MSFlexGrid1.col = col
    Set MSFlexGrid1.CellPicture = LoadPicture(PicturePath)
    MSFlexGrid1.Refresh
End Sub
Or u can add pictures to an ImageList Control
 and these images can be used to set in FlexGrid control
like this,

    Set MSFlexGrid1.CellPicture = ImageList1.ListImages(0).Picture  ' You can change ListImage index to get different pics
Avatar of mattjulius
mattjulius

ASKER

what I need is these images which serves as button (add,edit,delete) will loop according to the data in my databases.
ok that means
in each row of ur MsFlex u need to have buttons ADD,Edit and delete  ? right
and u need to handle click  events for each ?

for that u need to dedicate first 3 columns for images
How can I loop those images (w/c serves as button) in flexgrid with all of the data in there has images..
ASKER CERTIFIED SOLUTION
Avatar of Shiju S
Shiju S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes its working thanks BUT CAN I ASK  ONE MORE: HOW CAN I PUT MOUSE OVER ON THOSE PICTURE?
PLUS HOW CAN I merge column
i am at office right now and i havent tried these codes,

pls try and let me know the results

http://xtremevbtalk.com/showthread.php?t=53551
http://www.pbdr.com/vbtips/gen/Article-UsingFlexGrids(3).htm
http://www.codecomments.com/Visual_Basic_Controls/message711326.html

and the mouse over matter , i will try it out and inform u if its possible with Msflexgrid

Regards
Shiju
Thanks for the links...........

this link merge by cell by  column(fix column).
http://www.codecomments.com/Visual_Basic_Controls/message711326.html
What If instead of image i want a button? can I change your code as ( PicturePath As Button).
Hi mattjulius
that means ur column merge problem  solved ?

you can set only pictures there
you can place images of  buttons, so that it will look as if buttons (i recommend)

if u really want to place buttons,
u can have a seperate button and on click we can position the button so that it will look as it is inside the msflex column



     
Thanks a lot.
But is it possible to make mouse over?
Hi
u can make use  of MouseCol and MouseRow properties
here is a sample code for u to test

Private Sub MSFlexGrid1_LeaveCell()
    MSFlexGrid1.CellBackColor = MSFlexGrid1.BackColor
End Sub

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    MSFlexGrid1.col = MSFlexGrid1.MouseCol
    MSFlexGrid1.row = MSFlexGrid1.MouseRow
    MSFlexGrid1.CellBackColor = vbBlue
End Sub