Windows Develop Bookmark and Share   
 index > Windows Forms General > inaccessible text box in disable panel !!
 

inaccessible text box in disable panel !!

Hi

I'm converting a vb6 project to .Net. In vb6 I had a frame with many text boxes and other ctrls. whenever I disabled the frame I would have access to text boxes or other ctrls.for instance I could select the text inside the textbox even I couldn't change anything.But now in vb.Net all ctrls will be gray out and inaccessible. Is there anyone who over come this incompatibility?

  • Moved byTaylorMichaelLMVPFriday, September 18, 2009 1:35 PMWinForms related (From:.NET Base Class Library)
  •  
Koosha.E  Thursday, September 17, 2009 8:48 PM
Hmya, ReadOnly is only relevant to controls who's content can be changed. TextBox and RichTextBox. The user can't change the displayed content of a Panel. If you want it to work the same as VB6 you should use VB6.
Hans Passant.
nobugz  Friday, September 18, 2009 6:12 PM
Create a control that derives from Panel. Then add a ReadOnly property, like this:

        public bool ReadOnly
        {
            get
            {
                return m_readOnly;
            }
            set
            {
                m_readOnly = value;
                foreach (Control ctrl in Controls)
                {
                    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);
                    PropertyDescriptor pd = properties.Find("ReadOnly", false);
                    if (!object.ReferenceEquals(pd, null))
                    {
                        pd.SetValue(ctrl, m_readOnly);
                    }
                }
            }
        }


Once you have your custom panel, you can "enable/disable" by setting the new ReadOnly property on your own panel class. In turn, your panel class will cascade the ReadOnly setting to all controls contained if they support it.

Same thing can be done for other containers. Have fun.
MCP
webJose  Saturday, September 19, 2009 5:07 AM
Use the ReadOnly property instead of Enabled.

Hans Passant.
  • Marked As Answer bynobugzMVP, ModeratorFriday, September 18, 2009 10:50 AM
  • Proposed As Answer byThiago Valença Thursday, September 17, 2009 9:32 PM
  • Unmarked As Answer byKoosha.E Friday, September 18, 2009 1:58 PM
  • Unproposed As Answer byKoosha.E Friday, September 18, 2009 1:59 PM
  •  
nobugz  Thursday, September 17, 2009 9:18 PM
try locked property of the panel
CodeGuide  Friday, September 18, 2009 10:35 AM
there is no "locked" property or method for panel
Koosha.E  Friday, September 18, 2009 1:33 PM
there is no "readonly" property for panel .also a lot of controls don't have that property
Koosha.E  Friday, September 18, 2009 1:36 PM
Hmya, ReadOnly is only relevant to controls who's content can be changed. TextBox and RichTextBox. The user can't change the displayed content of a Panel. If you want it to work the same as VB6 you should use VB6.
Hans Passant.
nobugz  Friday, September 18, 2009 6:12 PM
Create a control that derives from Panel. Then add a ReadOnly property, like this:

        public bool ReadOnly
        {
            get
            {
                return m_readOnly;
            }
            set
            {
                m_readOnly = value;
                foreach (Control ctrl in Controls)
                {
                    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);
                    PropertyDescriptor pd = properties.Find("ReadOnly", false);
                    if (!object.ReferenceEquals(pd, null))
                    {
                        pd.SetValue(ctrl, m_readOnly);
                    }
                }
            }
        }


Once you have your custom panel, you can "enable/disable" by setting the new ReadOnly property on your own panel class. In turn, your panel class will cascade the ReadOnly setting to all controls contained if they support it.

Same thing can be done for other containers. Have fun.
MCP
webJose  Saturday, September 19, 2009 5:07 AM

You can use google to search for other answers

Custom Search

More Threads

• When i maximize a form the contents in it are not maximized
• Moving a minimized child form in MDI application
• how can I delay a windows form for 5 seconds in do until loop in VB?
• How to determine if a Label is rendering ellipses
• byte[] and Class convert
• capturing stdout not working properly
• How to remove imagemargin in a submenu
• How to display Access Key without press Alt key?
• Two listBox synchronization
• word 2007 UserControl