I have a DevExpress grid, which is disabled on screen. When I click the control, I want it to become enabled. Right now I have a click event set up for the grid:
private void gridPSR_Click(object sender, EventArgs e)
{
gridPSR.Enabled = true;
}
This isn't working. How should I be going about this?
Answer. Swap your disabled attribute for aria-disabled="true" . This will allow the element to maintain most of its properties that allow you to interact with it, but still keep its disabled status and announce itself to assistive technology as such.
Click 'Toggle" to make 'Button' enabled or disabled. click it, and see that that one event fires if it is enabled, and another if disabled.
Making a Controls (for example Text Controls, Text input, Label, Button, Dropdown Etc..) enable or disable on some conditions are very common requirement in Microsoft Power Apps. In my example, I have a text box Control in canvas App of Microsoft Power Apps and 2 Button i.e. “Enable” & “Disable”.
To disable any control with jQuery pass true as the second argument to the .prop () method. There is an input control and a button. On the button click event I will disable the input control. Here I have a disabled input control which I will enable on the button click. Sometimes you want to keep the submit button of a form disabled.
Don't try to position a clickable element above it but wrap it with one so you won’t directly be able to click it. Assuming a button with display: inline-block set: This allows you to easily react to a click even in case of a disabled button. See FIDDLE.
Disabled controls do not receive windows messages, so you will never get the click message on that control. Assuming this is Winforms, you can listen for the click on the form (or whatever control is hosting this grid) and check if the click location is in the rectangle of the disabled control and then enable the control accordingly:
void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (gridPSR.ClientRectangle.Contains(e.Location))
{
gridPSR.Enabled = true;
}
}
I know it's an old post but for me bounds worked instead of ClientRectangle
private void OnPanelMouseClick(object sender, MouseEventArgs e)
{
if ((e.Button == MouseButtons.Left) &&
myControl.Bounds.Contains(e.Location) &&
!myControl.Enabled)
{
myControl.Enabled = true;
}
}
Where myControl
is member variable of your control instance. OnPanelMouseClick
handler should be linked with MouseClick
event of form or container that holds control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With