Inheriting a Windows Form

  • Thread starter Thread starter Ed Willis
  • Start date Start date
E

Ed Willis

What is the best way to make a window read only for an inherited window. How
do I access the all the controls such as textboxes etc. to make everything
read only? I have an update window that I am inheriting and I am going to
make the inherited window read only.

Thanks.
 
Ed Willis said:
What is the best way to make a window read only for an inherited
window. How do I access the all the controls such as textboxes etc.
to make everything read only? I have an update window that I am
inheriting and I am going to make the inherited window read only.

Which property of the inherited Form do you want to make readonly? The
"Windows Forms Designer Generated Code" can (or should) only be modified by
the designer. If there is no setting to make a property Readonly, it is "not
possible".



--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
I want to make all textbox etc. controls that I can set to readonly or
disabled. I would like to do it programically by going through the window
and setting the propert of each control in the window. However the window
has a tabcontrol. I cannot figure out how to loop through all the controls
in the tab control tab pages?
 
Ed Willis said:
I want to make all textbox etc. controls that I can set to readonly
or disabled. I would like to do it programically by going through the
window and setting the propert of each control in the window. However
the window has a tabcontrol. I cannot figure out how to loop through
all the controls in the tab control tab pages?

Now I understand. I thought you want to make the declaration of the controls
readonly, something like

Friend Readonly Textbox1 as textbox

But that's not what you want.

This should work:

Private Sub EnumControls(ByVal Controls As Control.ControlCollection)
Dim c As Control
For Each c In Controls
if typeof c is textbox then
directcast(c, textbox).readonly = true
else
EnumControls(c.Controls)
end if
Next
End Sub


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Thanks. I actually had the code to do what you have but I cannot get
anything but the first tabpage to work. All the other tab pages are not
affected?
 
It worked. I enabled in the inherited window so once I fixed that it worked.

Thanks.
 
Back
Top