[英]WinForms & Infragistics controls readonly property does not work for clicked control
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). 它可以工作,但是如果用户单击一个控件(例如文本框),然后单击“编辑”按钮(调用makeReadOnly函数)。 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. “ this”表示父窗体。“ EditButton_Click()”是按钮事件。 Why it is not working for the clicked ones?
为什么对单击的人不起作用? How can I solve this problem?
我怎么解决这个问题?
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.
当用户单击UltraTextEditor或UltraComboEditor控件时,Infragistics会将其类型更改为“ EmbeddableUIText ...”之类,并且其父类型将变为UltraTextEditor或UltraComboEditor。 So, I have to check this types or controls' parent types to solve it.
因此,我必须检查这种类型或控件的父类型来解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.