How to change the background of picture using MouseEnter event??
1 view (last 30 days)
Show older comments
Hi..
I have import the System.Windows.Forms and System.Drawings.Bitmap in the code.. Can anybody please tell me how to change the background of PictureBox using MouseEnter event?? I have created a Form in Matlab using .Net library and i have a picture box, i want to change its background image as soon as the mouse come on it..
Thanks in advance..
0 Comments
Answers (1)
Jiro Doke
on 15 Feb 2011
I may not have the VB part well coded, but this should get you started.
function ln = formTest
NET.addAssembly('System.Windows.Forms');
f = System.Windows.Forms.Form;
f.Width = 640;
f.Height = 480;
p = System.Windows.Forms.PictureBox;
p.Width = 640;
p.Height = 480;
p.ImageLocation = which('street1.jpg');
f.Controls.Add(p);
f.Visible = true;
ln(1) = addlistener(p, 'MouseEnter', @mouseEnterFcn);
ln(2) = addlistener(p, 'MouseLeave', @mouseLeaveFcn);
function mouseEnterFcn(obj, edata)
obj.ImageLocation = which('street2.jpg');
function mouseLeaveFcn(obj, edata)
obj.ImageLocation = which('street1.jpg');
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!