winforms - C#: click (where applicable) versus validating event -


i working on windows forms visual c# , have bunch of radio buttons grouped together.

i needed call methods if radio button clicked , validation.

so have 2 methods,

public void dosomestuff()  public bool valradiobutton1() 

i can call dosomestuff() in click event , latter in validating event of radiobutton call both in either click event or validating event.

my question there advantages , disadvantages event use call these? or there particular way more efficient. right seems both events exact same thing why use 1 or or both.

radio buttons kind of strange in combination conventional validation. validating event seems designed allow validate value once when user done entering value instead of every time value changes user entering it. makes sense textbox want @ completed text instead of after each character user types. it's little more obscure radio buttons. in fact think should avoid validating event of radio buttons , instead use validating event of container (radio buttons should in embedded container). allows keyboard user select/move through different options arrive @ 1 want without repeated validations move through options. when move focus out of group box (or whatever container used), can validate whole option group @ once. behavior more consistent, then, of other controls' validation. in fact see little purpose using validating event on individual radio buttons. reason see if want cancel user's new selection without causing click events. aware when no radio button selected , user first clicks on one, no validating event occur! no radio button lost focus , validating events occur when control loses focus. why think should avoid validating event on radio buttons , use validating event of container or click event of radio button.

also, think if want nice keyboard users, should keep validation logic separate click logic , use events appropriately. things enabling controls based on option selected belong in click event of radio button, error , warning messages selected option should go in validating event of container.

edit: asked when 1 event occurs , not other. add information in response that:

  1. validate called without calling click if code causes selected radio button change, assuming focus passes radio button (or container, if using container's validate event).
  2. click called without (or should before) calling validate if no radio button selected , user clicks on 1 (validate occurs when control loses focus). validate occur clicked option, though.
  3. click called without (or should before) calling validate if validate handler not linked specific option selected or container. called option selected (and container) when option (or container) loses focus, though.
  4. click called without validate being called if code looks @ value doesn't require selected option lose focus before looking @ it.

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -