Simple question, but I didn't know what's the keywords to Google.
Suppose we want to adjust the height of the taskbar on Windows. When u place the mouse cursor at the edge of it, the cursor will change to an up and down arrow meaning that the taskbar is resizable.
How do I get that cursor to come out in C#?
Is there a control for it? Or do I have to check if the mouse is on the edge of the control, if it is change cursor. On click resize according to the difference?
You would put a splitter control onto the form, set it to horizontal, then put the control you want to be sizeable (taskbar, whatever) inside the splitter, go into the dock settings and dock it to all sides.
Related
I have a Winform I want to resize. Not after launching; I want to resize it in the designer by dragging the edges.
I am aware that I can change the size manually in the form properties. This is not what I want to do. I want to quickly size the default size of the form with my mouse.
The problem appears to be that I cannot grab the edges of the form for some reason. I repeat, this is NOT DURING RUNTIME. It is not that I have disabled/enabled Autosize/Resizing.
It's almost like the edge grabs are a single pixel wide and I just can't hit it. I don't know. I've looked for accessibility settings. The last thing I want to do is reinstall MSVS. It's just maddening.
I've attached a photo. The little boxes on the bottom, right, and bottom-right corner are my targets.
you can try to click the form title before resizing. I think you may have a panel (or any container control) which is full docked in the form, that's why when you click the form body, you selected the panel instead of the form.
Another issue that I encountered was the windows font size was set to 120% (or more), so go to windows display setting and set the font size to 100%.
How do I make it when the window is resized none of the controls are on one corner or just shrug away but become bigger or smaller to correspond with the window In Windows forms?
You need to Anchor your control(s) on the window.
Basically u (always) anchor your control on Top & Left (that's default anyway).
If you want to stretch your Control horizontal add Right.
For vertical stretching add Bottom.
[Properties] (rightclick the control you want to anchor and select properties)
Use Anchor property of each control to achieve the effect.
For example, if you set it to "Right, Bottom" on a control, it will keep its right and bottom side anchored (set to fixed distance) against the right and bottom edge of the form.
This is sufficient for basic sizing. For advanced sizing, you have to size your controls manually on window resize event.
You might also want to set MinimumSize property of your form to prevent its window to shrink under that size. This way you can prevent unwanted layout distortions like controls clipped or completely hidden behind right or bottom edge of the window.
I need some part of UI to behave like dock window, but not all. I wonder if that's possible to mix the two. Say, I want 3 datagrids to be fixed in their positions, but I want settings windows to dock on right side or in middle of main window, when mouse hovers on it, it will expand and show all settings, when mouse moves away, the setting window simply collapses. but I do not want the other 3 data grids to move or collapse. I'd like the data grid show up as normal, not like a dock document.
Thanks
Edit
My project uses both WPF and WinForms. So I am looking for solutions for both
Just dock the settings to the right and listen to the MouseEnter and MouseLeave events. Change the width of the settings to zero, or something very small, when MouseLeave, and back to full width on MouseEnter.
Resizing a docked control behaves very nicely.
How does one specify that a button centers itself in a container without having to specify a Location? Is it even possible?
The goal is to be able to center multiple buttons in a panel without having to perform calculations on their placement.
I know it is possible to center some controls on a form, not sure about a panel though. Anyway:
Disable the Left and Right anchors of your control if you want your controls to stay centered horizontally, and the Top and Bottom anchors if you want your controls to stay centered vertically,
In the designer window, select your control,
In the VS 'Format' menu, hit 'Center in form', then 'Horizontally' and/or 'Vertically'.
If you want to center several controls side to side, select them all and execute the above steps.
Controls will then stay centered in the form when the user resizes the window.
I'm not 100% sure of what you are asking, but try using a TableLayoutPanel, and drop one button in each cell of the table. If you anchor the TableLayoutPanel to the Top, Left, Bottom& Right, the Table will grow and shrink with the form, but each button will "float" relative to the top-left corner of it's containing cell.
Disabling all anchoring will keep the TableLayoutPanel at it's relative location within your form, but your buttons will remain spaced out evenly amongst one another.
Between standard control anchoring and/or the the TableLayoutPanel you should be able to find the correct type of anchoring that you desire.
I want to display a very small image on the top left corner of the windows desktop, it will be a picture of a small note and when you mouse over it, the window will show.
How can I do this in C#?
There should be no borders or regular window graphics
The image will be partially transparent
When a mouse over event occurs a window will display
The image will always overlay other windows
Thanks
I'll try to point you to the right direction for each of those requirements, you can do more research on how to exactly achieve each one using google or stackoverflow.com
You need to create a widows form, and add the image as the background of the form, or add an image control to the form.
after you have that, you can use the following to get your desired effects.
No Border
Set form's FormBoarderStyle propery to None
Transparency
Set Opacity property of the Form to something less than 100%
Mouse over
Use MouseHover or MouseEnter events of the form
Overlay other windows
Set TopMost property of the form to true.