How to change the background of picture using MouseEnter event??

1 view (last 30 days)
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..

Answers (1)

Jiro Doke
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');

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!