bwells Posted February 25, 2003 Posted February 25, 2003 I have a form that has several controls on it all in a panel. Sometimes, the user needs to have read-only access to this form. If I disable the panel, then indeed all controls get disabled. But you cannot tell by looking at the controls that they are disabled. I want to draw on top of the form a graphic that is translucent so everything on the form is dimmed. I might also like the graphic to have a big "X" on it, or perhaps even say the reason that the form is disabled. I tried several things, but nothing really works. I would be happy if I could even just draw a big red "X" over the form inside a red circle to indicate what I want. But if I draw on the form, my lines fall behind the panel and controls. So I tried placing two panels on the form. This works good, but the panels cannot be rotated, so I end up with a big "Cross" instead of an "X". So my question is how can I put a translucent image or rectangle that covers the entire form and all of its panels and controls? Or, how can I draw a line on a form so the line is drawn on top of all other panels and controls on the form? Or how can I rotate a panel so I can draw an "X" on top of the form which will cover all panels and controls on the form. Or can anyone suggest a better way to indicate to the user that a form is read-only while they are in a particular mode? I tried making a transparent gif and placing it in a picturebox, but the picturebox seemed to be transparent with respect to the parent form, so the controls on the form did not show. thanks Bryan Quote
billy_bob169 Posted February 26, 2003 Posted February 26, 2003 Have you tried adding the components on your form to a collection, then using the collection to enable or disable them all at once? Quote I'd rather be riding than working
UCM Posted February 27, 2003 Posted February 27, 2003 Try using a label and in code at runtime ( like in the _load event or something ) put the following code: label1.backcolor=argb(translucentcolor,red,green,blue) ( 0-255 ) translucentcolor ( 0-255 ) red ( 0-255 ) green ( 0-255 ) blue The translucentcolor attribute is how transparent/lucent a color will be, 0=transparent, 255=solid Also, when your panel is to be read-only, make the label's.visible property=true and make it false when you want the user to be able to modify it... Just make sure to put the label on the very front of all the controls. Quote UCM >-)
bwells Posted February 28, 2003 Author Posted February 28, 2003 The problem with this is that the label will be transparent with respect to its parent and not any thing in between. So when I do this, I see the form backcolor, but not any of the controls. I would have to parent all of the controls with the label, then it would work. Same with a picturebox. For the time being, I have just decided to color the background of the form a different color so it is obvious that it is different. Plus the form's controls are disabled, so when the user clicks on the form or any control, I catch the event and pop up a message telling them that they have to change other prooperties of the system to edit the control they are trying to change. thanks Bryan Quote
Ariez Posted February 28, 2003 Posted February 28, 2003 When a panel is diabled you can tell all the controls in it are disabled. In my opinion a bix X on a form is not very elegant. You could set that part of the form you want to disable as custom control. set any disable effects as a disable property of that control. import the control on the form and call that property at will... keep your forms light.. hope it helped... Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
bwells Posted February 28, 2003 Author Posted February 28, 2003 Yes, I did just what you suggested about a base class property that disables the container and as a result, all of the children controls. But in my case, you really cannot tell that the controls are disabled. Some are 3rd party controls, and others like a slider (trackbar) do not change when toggled between enabled/disabled. So my techique now is to change the background color so you can tell "something" is different. This works well enough and solves the problem. Quote
Ariez Posted February 28, 2003 Posted February 28, 2003 well like the old saying: ifitworks, itsgooood... Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.