CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2003
    Location
    Ft. Worth Texas
    Posts
    31

    How to set radioButton to checked without generating an event?

    I need to set a radioButon to checked and not generate a CheckedChanged event.

    The SendMessageA function doesn't seem to work in this case, probably because I wasn't able to locate a parameter to set the checked state.
    Did I just miss it?

    Where do I go from here?
    Any suggestions?

    Thanks!
    VS2010
    .Net 3.5
    Last edited by KKW; November 17th, 2013 at 11:06 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: How to set radioButton to checked without generating an event?

    I don't know how it works in C#, but what is wrong with BM_SETCHECK message?
    Victor Nijegorodov

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to set radioButton to checked without generating an event?

    SendMessage? Are you attempting to do this within the code of your own program or from a different process? If within the code, then remove the event handler, set the checked state, and re-add the handler.

    Code:
    myButton.CheckedChanged -= myCheckedChangeHandler(...);
    myButton.Checked = true;
    myButton.CheckedChanged += myCheckedChandeHandler(...).;
    Last edited by Arjay; November 17th, 2013 at 01:43 PM.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to set radioButton to checked without generating an event?

    Call me daft ( you won't be the first ), but why the need for this in the first place? Isn't an object on the form's sole function to generate some sort of event from the user? Or, am I just reading too much into this?

    The problem I can see is that your users will be very confused if the Radio Button doesn't function the way it is supposed to

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to set radioButton to checked without generating an event?

    Hannes, there are cases that you want to initially set a state based on some other user action.

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to set radioButton to checked without generating an event?

    I suppose you're right. Perhaps I'm reading too much in to it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured