Thursday, February 18, 2010

Enable and Disable a Control by Binding to another Control

You can Set the Enable Property of a control by binding that control to another control.

How to Achieve this?

See this code snippet.This is a Windows Application Project with C# language.
To test this code you should have a TextBox named "txtName" and a CheckBox named "chk".

In the form load event write this

txtName.DataBindings.Add("Enabled", chk, "Checked");
Execute code and check and uncheck CheckBox. So that you can find the TextBox's property changing.

No comments:

Post a Comment