Visual C++ Developer Center > Visual C++ Forums > Visual C++ Language > How to access the System::Windows::Controls::radiobutton->isChecked property
Ask a questionAsk a question
 

AnswerHow to access the System::Windows::Controls::radiobutton->isChecked property

  • Friday, November 06, 2009 10:55 AMAvinash Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    the property returns a nullable <of T > ,I want an boolean value for the checked state ; How to get this

    I declared a radiobutton as

    System::windows::controls::radiobutton ^ RdbC;

    then i used it in my .Cpp file after its initialization

    if(RdbC->IsChecked == true ) {}

    it gave error C2678 that no accessible conveter is avaliable for the conversion System::Nullable<of T> to type boolean

    how to correct the problem !!

    Have a nice day !!

Answers

  • Friday, November 06, 2009 3:56 PMViorel_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Try this:

     

        Nullable<bool> c = RdbC->IsChecked;

        bool is_checked = c.HasValue && c.Value;

        if( is_checked ) . . .

     

    and this:

     

        if(RdbC->IsChecked.GetValueOrDefault()) . . .

    • Marked As Answer byAvinash Rai Sunday, November 08, 2009 8:57 AM
    •  

All Replies

  • Friday, November 06, 2009 11:31 AMBharath kumar Y.S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    use


    if(RdbC->Checked == true)
    {

    //code to perfrom if radi box is checked
     }

  • Friday, November 06, 2009 3:15 PMAvinash Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    thank you for viewing this thread !!

    But what u suggested doesnt help me at all --Mind you I am using System::Windows::Controls namespace and that radiobutton is derived from there -- That does not have the property called Checked at all !!

    Only Forms::Radiobox support this property !!

    All it supports is IsChecked property that gives the Return value as of type System::NUllable(of T)

    The problem is how can i get the Ischecked property as bool (True or false)

    Hope U now will understand the situation !!

    Have a nice day !!
  • Friday, November 06, 2009 3:56 PMViorel_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Try this:

     

        Nullable<bool> c = RdbC->IsChecked;

        bool is_checked = c.HasValue && c.Value;

        if( is_checked ) . . .

     

    and this:

     

        if(RdbC->IsChecked.GetValueOrDefault()) . . .

    • Marked As Answer byAvinash Rai Sunday, November 08, 2009 8:57 AM
    •