I think, I found the answer. The problem is in Infragistics controls. When a user clicks an UltraTextEditor or UltraComboEditor controls, Infragistics changes its type to something like "EmbeddableUIText..." and its parent type becomes UltraTextEditor or UltraComboEditor. So, I have to check this types or controls' parent types to solve it.
WinForms & Infragistics controls readonly property does not work for clicked control
-
08-07-2023 - |
문제
I wrote this code to make all controls readonly.
makeReadOnly(Control control, bool bIsReadOnly)
{
for(int i=0; i< control.Controls.Count; i++)
{
if(control.Controls[i].Controls.Count > 0)
{
makeReadOnly(control.Controls[i], bIsReadOnly);
}
else if(control.Controls[i].GetType() == typeof(UltraTextEditor))
{
(control.Controls[i] as UltraTextEditor).ReadOnly = bIsReadOnly;
}
else if(control.Controls[i].GetType() == typeof(UltraNumericEditor))
{
(control.Controls[i] as UltraNumericEditor).ReadOnly = bIsReadOnly;
}
else if(control.Controls[i].GetType() == typeof(ListBox))
{
(control.Controls[i] as ListBox).Enable = !bIsReadOnly;
}
}
}
It works but if user clicks one control such as a textbox, then click edit button(call makeReadOnly function). Function does not work for the clicked textbox. (It works for the other controls only).
Private void EditButton_Click()
{
foreach(Controls control in this.controls)
{
makeReadOnly(control, false);
}
}
"this" represents parent form."EditButton_Click()" is button event. Why it is not working for the clicked ones? How can I solve this problem?
해결책
제휴하지 않습니다 StackOverflow