1
Guys good night how are you? I have a form, with a tabpage, and with some textbox, I’m trying to deploy in the page load, that the property isreadonly is true.
but I’m not getting it, I’m using the following condition:
private void Comercial_Load(object sender, EventArgs e)
{
foreach (Control ctl in tabControl1.Controls)
if(ctl is TabPage)
{
((DevExpress.XtraEditors.TextEdit)(ctl)).ReadOnly = true;
((TextBox)(ctl)).ReadOnly = true;
}
xtraTabPage1.PageVisible = false;
xtraTabPage2.PageVisible = false;
xtraTabPage3.PageVisible = false;
xtraTabPage4.PageVisible = false;
}
but when executing, the error is returned:
Additional information: Cannot convert a 'System.Windows.Forms.Tabpage' object to 'Devexpress.XtraEditors.Textedit'.
After our friend’s comment, I tried again, but still unsuccessful:
foreach (Control ctl in xtraTabControl1.Controls)
if (ctl is TextEdit)
{
((TextEdit)(ctl)).Enabled = false;
}
Thanks
Young man, there is a Devexpress component there that changes a little your scenario :-D
– Marco Aurelio
Friend, even removing that component, it is not rolling, I did so, and also in:
– Thomas Erich Pimentel
Try using . NET native components in foreach to see if it works... you need a different treatment for Devexpress components
– Marco Aurelio
Um.. I am using the DX xtraTabcontrol, I will switch to the . net tabcontrol and try. Thank you
– Thomas Erich Pimentel
Even checking if it is a textEdit do you cast? Tried without the cast? What error returns?
– Marco Aurelio
In the second way, it does not return any error, only that when executing the application, the textedit is not read-only.
– Thomas Erich Pimentel