Environment: Visual studio VB or C#
I have some problem about layer of control. My user control has a panel it's set color to be transparent. In main form I create new instant of user control .But a panel of user control is not transparent.
Ok,a background of user control change to same a background of a main form.
but when I use Ctrl.bringToFront()
a panel of user control will cover all of existing control on the form.
Below image, I add user control to main form. MainForm has green panel. all of them is cover by user control.
I try to use a label control. it has a same problem.
According to third image a label should be blue and red color.
What should i do? if my user control is not rectangle. In my user control,I must use panel for combine many control.it' easy for move or resize.
Related
I've made my own custom ownerdrawn button control, inherited from the Button class itself. I draw the control all by myself in the OnPaint override procedure, this includes painting the background of the button, drawing its borders, text and image.
I also need to incorporate the capability for the button to show an Active color border in case the button has focus, or is defined as the AcceptButton by the parent form. For focus, I use this.ContainsFocus to know if the button currently has focus.
How to know if my button control is defined as the default AcceptButton on the parent form, so I can draw the active border color around it accordingly? I don't see any inherited property in the Button class to find this out.
Thanks.
I have a flowlayoutpanel, on which there are some UserControls, which are being dragged and dropped in flowlayoutpanel. I need my controls - userCOntrols to auto resize when resizing the window itself. I need that Usercontrols to be resized automatically when resizing the form.
What can you offer ?
You should use the Dock Property for that.
How to dock a control:
Select the control that you want to dock.
In the Properties window, click the arrow to the right of the Dock property.
An editor is displayed that shows a series of boxes representing the edges and the center of the form.
Click the button that represents the edge of the form where you want to dock the control. To fill the contents of the control's form or container control, click the center box. Click (none) to disable docking.
The control is automatically resized to fit the boundaries of the docked edge.
this is my customized form by overriding paint event and implemented form features such as moving ,resizing and some new capabilities. i have a problem with this that all of my form area is accessible for example when i set dock property of a control to fill the control will spread on entire form and border will disapear. i wanna to have a separated and not accessible area for border like c# Forms . how can i do it?
tanks for your help
I have a System.Windows.Forms.ToolStrip which contains a Label.
The ToolStrip has a special fancy background. But the label is just gray.
It's not possible to use transparency because the parent of ToolStrip is a form. Also it's not possible to change the parent, because the collection of Controls in ToolStrip is read only.
Is it possible to create a Label that is transparent and which has a ToolStrip parent?
Give the following a shot.
Set the backcolor of the label to Color.Transparent.
Then you have to add the label directly to the control collection of the control of which you want the label to appear transparent on top of.
If you just delete the assigned background color of the ToolStripLabel then it ought to inherit the background of its parent ToolStrip. I use a custom ToolStripRenderer to draw a customized background for tool strips, and my labels do not need any special handling in order to inherit the parent's background. Just make sure you aren't trying to assign a background color.
I am unable to figure out how to make my user control react to the resize event of a form.
The usercontrol(s) exist in a tab control of my main form.
The usercontrol(s) are anchored to all sides of the tab control or is it tab page?
The tab control is anchored to all sides of the form.
When I resize my main form the tab control resizes correctly but the usercontrol does not.
[SUMMARY]
DataBoxUserControl
- A user control with a button and a textbox.
- The textbox has it's sides anchored to the usercontrol.
MainForm
- Has a tabcontrol that is anchored to all sides of the form.
- The tab controls have my DataBoxUserControl which has it's sides anchored to the tab control.
Resizing the MainForm resizes the tab control but not the user control.
[WHAT ELSE HAVE I TRIED]
1. I've tried placing a panel control in each tab page and anchoring the panel. Then I placed the user control in the panel and anchor it. Either I'm doing it wrong but that didn't work either.
2. I read somewhere to try register the resize event of the main form to the user control. But I don't really understand that and I can't seem to find where I saw that again.
I am using c# and .net 3.5
I believe you need to set the dock property of the user control to "fill" to have it auto resize to an area.