none
Excel 2013 PictureBox Click Event isn't working | Bug RRS feed

  • Question

  • Hello

    I have written an VSTO --> excel book with Visual Studio 2010. In Excel 2010 works all perfectly. Unfortunately, in Excel 2013 didn't work the picturebox event "click". I have convert the project from VS10 to VS13.

    But when I changed the sheet and then go back to the sheet with the picturebox, the event is running. after scolling it stops working.

    Before scrolling:

    http://i60.tinypic.com/ipz7s4.jpg

    after scrolling. messagebox isn't work. Change the sheet or activate and deactivate the design mode. then works, looks like picture in top

    http://i61.tinypic.com/2cgn7lh.jpg

    Testet with:

    c#

    vb.net

    Excel 2013 Version 15.0.4569.1506

    Thanks

    Saturday, June 21, 2014 1:22 PM

Answers

  • Hi,

    I tried to reproduce your issue with the VSTO code below but the onclick event of the PictureBox works well after scrolling in my Excel 2013 (Version 15.0.4569.1506).

    private void AddPicturebox()
    {
        Microsoft.Office.Interop.Excel.Worksheet nativeWorksheet = Globals.ThisAddIn.Application.ActiveSheet;
        Microsoft.Office.Tools.Excel.Worksheet vstoWorksheet = Globals.Factory.GetVstoObject(nativeWorksheet);
        Microsoft.Office.Tools.Excel.Controls.PictureBox pictureBox = vstoWorksheet.Controls.AddPictureBox(nativeWorksheet.Range["D20:H28"], "PictureBox1");
        pictureBox.Image = Image.FromFile(@"C:\Users\Pictures\images1.jpg");
        pictureBox.Click += pictureBox_Click;
    }
    
    void pictureBox_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Test");
    }

    I suggest you checking your code referring to the code above and checking whether there is other add-in or code which affects the result. If there is no issue with the code, you could run it in other machine with Excel 2013 to check whether the issue is related to the Excel application. Then you could repair or reinstall the Excel 2013 to solve it. If the issue is related to the code, you could also share the code for us to troubleshoot.

    >>I have convert the project from VS10 to VS13.<<

    By the way, how do you convert the project from VS10 to VS13? I think you could try to create a new VS2013 project, copy the code and add the reference of Microsoft Office Interop for Excel 2013.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by rinuWS Thursday, June 26, 2014 3:38 PM
    Monday, June 23, 2014 8:11 AM
    Moderator
  • Hey,

    thanks a lot! this code works.

    The different between your and my code is, I work with the toolbox. I create my pictureBox with Drag&Drop from toolbox into the excel sheet, and this isn't work after scrolling.

    I found a solution for my problem:

    Control Panel -> System -> Advenced system Settings -> Performace Settings...-> register "Visual Effects" -> [..] Animate controls and elements inside windows

    A solution with both variants:

    http://www.file-upload.net/download-9126490/ExcelTest.zip.html

    Thursday, June 26, 2014 3:51 PM

All replies

  • Hi,

    I tried to reproduce your issue with the VSTO code below but the onclick event of the PictureBox works well after scrolling in my Excel 2013 (Version 15.0.4569.1506).

    private void AddPicturebox()
    {
        Microsoft.Office.Interop.Excel.Worksheet nativeWorksheet = Globals.ThisAddIn.Application.ActiveSheet;
        Microsoft.Office.Tools.Excel.Worksheet vstoWorksheet = Globals.Factory.GetVstoObject(nativeWorksheet);
        Microsoft.Office.Tools.Excel.Controls.PictureBox pictureBox = vstoWorksheet.Controls.AddPictureBox(nativeWorksheet.Range["D20:H28"], "PictureBox1");
        pictureBox.Image = Image.FromFile(@"C:\Users\Pictures\images1.jpg");
        pictureBox.Click += pictureBox_Click;
    }
    
    void pictureBox_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Test");
    }

    I suggest you checking your code referring to the code above and checking whether there is other add-in or code which affects the result. If there is no issue with the code, you could run it in other machine with Excel 2013 to check whether the issue is related to the Excel application. Then you could repair or reinstall the Excel 2013 to solve it. If the issue is related to the code, you could also share the code for us to troubleshoot.

    >>I have convert the project from VS10 to VS13.<<

    By the way, how do you convert the project from VS10 to VS13? I think you could try to create a new VS2013 project, copy the code and add the reference of Microsoft Office Interop for Excel 2013.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by rinuWS Thursday, June 26, 2014 3:38 PM
    Monday, June 23, 2014 8:11 AM
    Moderator
  • Hey,

    thanks a lot! this code works.

    The different between your and my code is, I work with the toolbox. I create my pictureBox with Drag&Drop from toolbox into the excel sheet, and this isn't work after scrolling.

    I found a solution for my problem:

    Control Panel -> System -> Advenced system Settings -> Performace Settings...-> register "Visual Effects" -> [..] Animate controls and elements inside windows

    A solution with both variants:

    http://www.file-upload.net/download-9126490/ExcelTest.zip.html

    Thursday, June 26, 2014 3:51 PM