none
Unable to cast object of type Microsoft.Office.Tools.Ribbon.RibbonDropDownItem to type System.IConvertible ??? RRS feed

  • Question

  • Hello there 

    I have problem passing value using below Code 

     private void dropDown2_SelectionChanged(object sender, RibbonControlEventArgs e)
        {
          Globals.ThisDocument.GetSurvData(Convert.ToInt32(dropDown2.SelectedItem));
        }
    

    i'm getting this error 

     

    Unable to cast object of type 'Microsoft.Office.Tools.Ribbon.RibbonDropDownItem' to type 'System.IConvertible'.

     

    is there any solution please !!!

     

    Salam

    Friday, May 6, 2011 12:42 PM

Answers

  • I got it sir ..

    thank you ...

    it should be as :

     

    private void dropDown2_SelectionChanged(object sender, RibbonControlEventArgs e)
      {
       Globals.ThisDocument.GetSurvData(Convert.ToInt32(dropDown2.SelectedItem.Tag));
      }


    Thank you sir ...

    Saturday, May 7, 2011 12:02 PM

All replies

  • Hi Salam

    The SelectedItem object has a Label property, which will return a STRING. As long as the string can be converted to an integer, that should work for you, I think .-)


    Cindy Meister, VSTO/Word MVP
    Saturday, May 7, 2011 10:13 AM
    Moderator
  • I got it sir ..

    thank you ...

    it should be as :

     

    private void dropDown2_SelectionChanged(object sender, RibbonControlEventArgs e)
      {
       Globals.ThisDocument.GetSurvData(Convert.ToInt32(dropDown2.SelectedItem.Tag));
      }


    Thank you sir ...

    Saturday, May 7, 2011 12:02 PM