Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Consistently Formatting Controls for Locking/Unlocking Editing
 

Consistently Formatting Controls for Locking/Unlocking Editing

I have a Windows Form with TextBox, ComboBox, DateTimePicker, and DataGridView controls. I want to lock all controls from editing until the user clicks an "Edit" button. Additionally, I need all controls to have consistent formatting while in this uneditable mode.

For ease of reading I prefer the black ControlText of the TextBox in ReadOnly mode. I wish all controls had a ReadOnly mode. I have tried to disable all other controls and set their ForeColor property to KnownColor.ControlText without success, they just remain gray -- which is difficult to read.

Alternatively, disabling the controls doesn't provide uniformity either. When I disable the DataGridView, it does not gray-out like the other controls do. I have to manually modify the DataGridView to resemble the other disabled controls.

I thought about making a read-only form that would launch an editable form for the specific record at hand but many of my fields are ComboBox/DropDownLists that wire a FK ID to the PK in another table. ComboBoxes make this very easy to do.

Any easy-on-the-eyes, easy-to-implement suggestions?
Decathlete  Monday, September 14, 2009 6:12 PM
Hello Decathlete,

Thanks for your post on MSDN forum.

Not all controls in WinForm have the ReadOnly property to let user make the control in a uneditable mode(e.g. ComboBox control).For those controls whichdon't have the BackColor property to SystemColors.Control, and use a transparent panel to cover those controls to prevent users form navigating to the control by clicking on it. We also need to set the TabStop to false to prevent focusing on that control. To create a transparent panel, please check my thread below.

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/60a11011-a1e2-4c5a-b09a-136c815c68ea

Let me know if this helps. If you have any additional question, welcome to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Tuesday, September 15, 2009 10:33 AM
Hello Decathlete,

Thanks for your post on MSDN forum.

Not all controls in WinForm have the ReadOnly property to let user make the control in a uneditable mode(e.g. ComboBox control).For those controls whichdon't have the BackColor property to SystemColors.Control, and use a transparent panel to cover those controls to prevent users form navigating to the control by clicking on it. We also need to set the TabStop to false to prevent focusing on that control. To create a transparent panel, please check my thread below.

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/60a11011-a1e2-4c5a-b09a-136c815c68ea

Let me know if this helps. If you have any additional question, welcome to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Tuesday, September 15, 2009 10:33 AM

Hello Decathlete,

Have you got any progress on this issue? If there is anything else we can help, welcome to post here.

Have a great day!

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Thursday, September 17, 2009 3:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Problem with DataGrid in Inherited Form
• DataGridView - what event fires when the grid is updated?
• Multi Threading
• Smart Client Application
• How to run time grey out a value (read only) in property grid?
• Concurrency Violation
• SortArrow visual style problem
• GeidView Button and Link Fields
• DatagridviewComboBox Datatype
• Sorting an unbound column