c# - Call SelectedIndexChanged on ComboBox within User Control -


i using .net 4 , trying create customcontrol when add customcontrol onto windows form, want have access selectedindexchanged combobox within user control.

basically, want when combo box triggers selected indexchanged, run code within windows form.

below have far.

public partial class customcontrol : usercontrol  ...  private void uicombobox_selectedindexchanged(object sender, eventargs e) {  } 

what best way want?

any appreciated.

if uicombobox placed within user control (named customcontrol), can wire handler in constructor follows:

uicombobox.selectedindexchanged += uicombobox_selectedindexchanged; 

if on other hand, uicombobox placed outside customcontrol, you'd need handle event using above technique , manually invoke method in customcontrol.

public class myform:form {     myform(){         uicombobox.selectedindexchanged += uicombobox_selectedindexchanged;     }      private void uicombobox_selectedindexchanged(object sender, eventargs e)       {         customcontrol.invokesomemethod(xxx);     } } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -