MSDN > フォーラム ホーム > Visual C++ Language > How to access the System::Windows::Controls::radiobutton->isChecked property
質問する質問する
 

回答済みHow to access the System::Windows::Controls::radiobutton->isChecked property

  • 2009年11月6日 10:55Avinash Rai ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    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 !!

回答

  • 2009年11月6日 15:56Viorel_MVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Try this:

     

        Nullable<bool> c = RdbC->IsChecked;

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

        if( is_checked ) . . .

     

    and this:

     

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

すべての返信

  • 2009年11月6日 11:31Bharath kumar Y.S ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    use


    if(RdbC->Checked == true)
    {

    //code to perfrom if radi box is checked
     }

  • 2009年11月6日 15:15Avinash Rai ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    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 !!
  • 2009年11月6日 15:56Viorel_MVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Try this:

     

        Nullable<bool> c = RdbC->IsChecked;

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

        if( is_checked ) . . .

     

    and this:

     

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