VB .net help

fez

fez

Caporegime
Joined
22 Aug 2008
Posts
28,010
Location
Tunbridge Wells
Right,

Quick question for all you VB or C# buffs out there.

I have a panel with a load of controls on and I wish to stop the controls on that panel from being edited. Can I put a transparent panel over the top and add or remove that to stop edits or allow.

Thanks
 
You could, but wouldn't you be best off just setting the Enabled property on the controls to false?

Just loop round the Controls collection of the panel and set the property on each control.
 
In Java you would just enable/disable the controls as necessary, can't you do that? Put all of the elements in some sort of collection and iterate over it setting the enabled/disabled property.
 
why not just disable the panel...?

Other than that you can do...

Code:
For Each Ctrl as Control in MyPanel.Controls

Ctrl.Enabled = False

Next

But this should achieve the same thing...

Code:
MyPanel.Enabled = False
 
Cheers guys but I dont like the fact that enabled = false greys out the control and its contents. I have used looping over the controls in the panel to set them all to disabled before but I was wondering if there was another way.

Sorry, forgot to say in the original post that I knew how to loop over and disable them but was after a more aesthetic solution.
 
Cheers guys but I dont like the fact that enabled = false greys out the control and its contents. I have used looping over the controls in the panel to set them all to disabled before but I was wondering if there was another way.

Sorry, forgot to say in the original post that I knew how to loop over and disable them but was after a more aesthetic solution.

Have to ask, why don't you want them greyed out? Surely this a good thing because it's showing your user that you simply can't use the control because it's disabled.

Unless you're using the controls to present text, in which case don't use "Enabled=False" but use "ReadOnly=True". This will stop editing but keep the control looking 'active'.
 
Surely this a good thing because it's showing your user that you simply can't use the control because it's disabled.

Agreed - it's not a good idea to have an enabled button look identical to a disabled button. The user is very likely to click it and think it's broken when it doesn't do anything.
 
This is for a custom piece of software with a design that runs throughout where users must click an edit button that is always in the same location in the menu to be able to edit anything in that screen. That should hopefully avoid the issue with users thinking its broken when they click.

Its a property letting piece of software that about 200 people use who are all trained in it as well.

Cheers for all the replies guys, will try the readonly suggestion.
 
Back
Top Bottom