TabControl with Big Icon - c#

My Windows Forms Applications project has a TabControl with Imagelist. What I need is square tabs with big Icons and Labels aligned Bottom.
Any suggestions?

I presume you mean you would like to change the tab "labels"
I don't think you can put the label underneath the image on a TabControl using just properties; but you could edit the images to contain the text. You can then remove the text from each TabPage to rely entirely on your images.
To make the tabs "square" set the SizeMode to Fixed and set your own size values (e.g. 42,42). You can then set the ImageSize to something similar (e.g. 40,40).
That should achieve what you are after, although you will have to update your images...
note: ImageSize property is a "subproperty" of the Images property of the TabControl.
note: As Hans Passant has said above, it seems you can put text under image by setting DrawMode and handling DrawItem - see this question: Windows Forms C# TabControl ImageList Alignment?.

Related

Make WPF Usercontrol resize entirely

In my application I have one frame resource and lots of icons resources. All of them are Path types. I would like to make a Usercontrol using the frame and one icon. The image bellow shows it better than any words:
I tried to make two grids, one overlapping another. On the icon grid I set the margins so the icon could fit correctly. But when I use this control in another place and resize it WPF tries to keep the margin values I set if it's too small the icon disappears from the frame. Is there any way to achieve this in WPF or do I have to duplicate all my icon paths to include the frame?
You can wrap your UserControl content inside a ViewBox. This will allow your content to scale correctly when the control is resized.

How can I make the background-image of a tabpage spread out to the available size?

I want to make the backgroundImage of my tabPages spread out to the available size.
According to other topics here on StackOverflow, I set the BackgroundImageLayout in my Forms properties to Stretch, but my background image is still being displayed as a tile.
Is there another flag I have to set? I feel like the seemingly global property does not quite affect tabPages.
PS: If it is of any significant matter, the picture is being added at runtime.
EDIT: This is how my Picture is being added to the tabpage as background:
TabPage tab = new TabPage();
tab.BackgroundImage = Image.FromFile(*path*);
tabControl.TabPages.Add(tab);
while tabControl is passed as a parameter inside the class, coming straight from my Form via this.tabControl
The fetching of the image works.
Also, the stretch attribute is currently set inside the forms properties.
a BackgroundImage object has more properties, and one of those is the placement of the image constrains... the available layouts are:
None
Tile
Center
Stretch
Zoom
play with those and choose the one that fit your needs:
tab.BackgroundImageLayout = ImageLayout.Stretch;
as it probably be a fixed layout, you can also use the UI for given the correct layout, but it's up to you...

C# positioning buttons

I have 3 buttons in my form. What I need to do is when I make the actual form bigger or smaller, the buttons should change their position and size so they look good, so they wouldn't remain the same size and position. I tried to use the anchors, but that does not work very well. What can I use to solve my problem?
You can check dock and anchor properties
http://www.youtube.com/watch?v=afsx1IJULLI
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx
You should set both left and right, or top and bottom anchors to resize control. If you'll set only one anchor from these pairs, then control will be positioned instead of resizing.
Docking will resize control, because it is equivalent of setting three or more anchors.
Try using TableLayoutPanel, put your buttons inside the columns of the table
Look good is different all the time. I like placing buttons in StackPanel and setting AutoSize property to true. This fixes two issues:
If user has 150% font in Windows settings - your UI does not break;
if you resize window to be very small - your buttons do not enforce minimal width/height and adapt to ratio user has chosen

How to change size and image in TabControl

I want to change size of TabPage in my TabControl,
each tab should be in one line without scroll.
the second question is about how to change Text into Image like here (Please, ignore the green line):
edit. I used Winforms.
Ad 1.
There is no way to adjust width of tab pages to fit width you want automatically, so you just have to do some maths to achieve this.
Ad 2.
First you have to create an ImageList object, which you will then pass to your TabControl:
ImageList il = new ImageList();
il.Images.Add("your_graphics_name", Image.FromFile(#"C:\Graphics\example.png"));
(...)
yourTabControl.ImageList = il;
Then you can set specific image from your image list on your tab page by giving it's key:
yourTabControl.TabPages.Add("title", "text", "your_graphics_name");
The size and layout of tabs is quite strictly controlled in WinForms. You can of course change the font and font size which will have an implicit effect on the size of the tabs, but this isn't what you want to do by the sounds of things.
Now apparently Windows does allow you to regulate the minimum default tab width, but you can't do it directly with the out-of-the-box WinForm control. This article explains how: How can i make WinForms TabPage header width fit it's title?.
You may want to consider a 3rd party tab control if this begins to pose a serious problem for you design-wise.
Like others said you can't change width of your tabs. But you can make your tabs for example in two rows, if they don't match the screen:
tabControl.Multiline = true;

Windows Forms C# Panel should not have white background, and panel should be only image

I have a windows forms, i have placed an image on it, and the image is not rectangular, so white space lefts with it, because windows form is either square or rectangular, but image is not, i want panel should be only image, rest of the space should not be visible, i am attaching an image to describe further.
Thanks
Atif
as I understand it you want your form to be invisible?
that isn't supported well in winforms and you should consider moving to WPF.
however theres this example:
http://www.blackbeltcoder.com/Articles/winforms/non-rectangular-splash-screen-for-winforms
create a splash screen as the writer advices.
I think you have set form properties [BackgroundImageLayout:stretch] or
you have to change image size(width,height) same as form size(width,height)
Read the ImageSize before applying to the form.
Resize the form with the image size.
If you can set the ControlBox property of the Form, you can even hide the Close, Maximize and Minimize buttons from the right top corner.
So you mean to stretch your image to the window frame? Just dock the picturebox to full form size. There is an option called Dock in parent container. Use that
You need to set the BackgroundImageLayout property to ImageLayout.Stretch, ImageLayout.Zoom or ImageLayout.Tile depending on how you want the image to fill the Form.
Put the image on the form directly by setting the following properties:
Form1.BackgroundImage = MyBackgroundImage
Form1.BackgroundImageLayout = Stretch

Categories