Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void cbotitle_Click(object sender, EventArgs e)
      {
          if (cbotitle.Enabled == false)
              cbotitle.Enabled = true;

      }
Posted

1 solution

The provided code will disable/enable a textbox on button click.

All you have to do is swap cboaccount1 with your combo box and it will work.

C#
private void button2_Click(object sender, EventArgs e)
{
     cboaccount1.Enabled = cboaccount1.Enabled ? false : true;
}
 
Share this answer
 
Comments
zeshanazam 14-Jan-13 23:20pm    
i want it to enable by mouse click on combo box...
David_Wimbley 14-Jan-13 23:23pm    
The problem with disabling a control that your trying to attach an event to that will automatically enable it is that if a control is disabled (enabled = false) that control stops listening to events as its disabled.

Is it possible to have an alternative of read only and that way the control can still actively listen for events?

This would require you simply catch the key press and handling it accordingly through the keypressdown (i think thats right) or keypressup (i think thats right?) events.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900