runtime menu icons

tushar149

Member
Joined
Mar 26, 2005
Messages
9
Programming Experience
1-3
how to attach icon in menu at run time. I have created run time menus
where data for creating menus is access from sql server. But i am stuck up where i want to attach icon as well. I will store images in sql server but how will i attach that icons to menus at runtime.
Can anyone suggest me how to do this. I am using vb.net 2003 and sql server 2000. Please it's an urgent.
 
Adding icons to the imageList before proceed them to the menuItems would be the best in this case.

1. Fetch the icons from DB
2. Add the icons to the ImageList - ImageList1.Images.Add(myIcon)
3. Draw the icon on the menuitem - e.Graphics.DrawImage(ImageList1.Images(1), 0, 0)





HTH
Regads ;)


btw, everything here is an urgent :D
 
Thanks for reply.

I got your idea but problem is that how could i get the draw_item event of menu because i am generating menu's at runtime ie. from database. How could i generate draw_item event of menu?? Because i have to write this code(e.Graphics.DrawImage(ImageList1.Images(1), 0, 0)) in draw_item event but when i generate menu at runtime i don't get any such events.


Thanks for reply again
Waiting for your quick reply again.
Tushar
 
Thanks for reply again.

Can you pl give me an example of how exactly we can use addhandler. In my code i have declare array of menuitems which is getting delcared for number of records in table in for loop, so how can i declare addhandler. Can you just give me example? it would be great help for me.

Thanks once again
Tushar
 
i have added addhandler code but drawitem event is not getting fired i don't know why

for e.g. i will give you an example of what i am doing:

and in form load event i have written a statement:

addhandler mnusave.drawitem,addressof fncopen1

than why this drawitem event is not getting fired..can anybody suggess anythig. please..

Private Sub fncOpen1(ByVal obj As Object, ByVal ea As DrawItemEventArgs) msgbox("hi")
Dim ic As New Icon("vuicon.ico")
End Sub

 
sorry for that posting it was bymistake.

i have added addhandler code but drawitem event is not getting fired i don't know why nenuitem's drawitem event is getting fired.

for e.g. i will give you an example of what i am doing:

In form load event i have written a statement:

addhandler mnusave.drawitem,addressof fncopen1

than why this drawitem event is not getting fired..can anybody suggess anythig. please..

PrivateSub fncOpen1(ByVal obj AsObject, ByVal ea As DrawItemEventArgs) msgbox("hi")
Dim ic AsNew Icon("vuicon.ico")
EndSub

 
Back
Top