i am trying to create a POS system, and there will be buttons creating dynamically, wondering what is the best way to create or layout the buttons.
I am currently using Metro Framework for C# window form, is there a way to create a pannel to have fixed amount of rows, and x columns of buttons so that if it has more than x columns, it will generate a scroll bar for you to slide to the rest of the buttons.
thank you
Related
I am developing a C# WinForm application.
I am using cartesianchart from LiveChar.Winforms.I want to do a scrollable graph.
I added too many items on chart and the chart fit all items to area. I want to put scroll bar bottom of cartesianchart thus items not to be stuck viewing area.
I m developing a window optimization application in C#. In that Project I have tablelayout panel. And i added pictureboxes to all cells. In application the user can add columns and rows at run-time.
But when the user dynamically add column or row, the application begins to slow down.
My question is with using panel instead of pictureboxes will speed up? (Panel backround image property do same job) Or it doesn't change anything?
I have already set double buffered proterty to true.
I have tablelayout panel. And i added pictureboxes to all cells.
If I understand you correctly, this won't work in WinForms. Here all controls are actual Windows windows, with OS-level handles and all the message pumping logic that entails. Plus the table layout triggers resizing in every single window under it, putting more pressure on it all.
Either go the less lazy route of drawing it all yourself in a memory bitmap and put it in a PictureBox to display, or use a more modern framework like WPF which doesn't have any of the afore-mentioned limitations. In fact, this is trivial in XAML.
I am developing a c# application using windows forms and I wonder if it is possible to make the application responsive somehow, I've searched a lot and found that the anchor could be used but it doesn't resize things so it doesn't look responsive, is there a way that I can make c# responsive desktop applications?
For Example:
Here when I maximize the pannels they fit the window but the text will just look bad.
Before Maximization
After Maximization
If you want to simply distribute the components in the maximized window, without scale the components up, I suggest you use the TableLayoutPanel, instead of the Panel.
Using a TableLayoutPanel, you can divide the screen, for instance in 4 parts, 2 columns and 2 rows with 25% in each. And then distribute the components. Don't forget to set the Dock property of TableLayoutPanel to fill, or set the anchor property appropriately.
You can Stil put a FlowLayoutPanel inside the TableLayoutPanle row, doing that will provide a dynamic layout for the child controls that can be arranged horizontally or vertically.
Search for TableLayoutPanel to get some samples.
Some articles about it:
https://www.codeproject.com/Articles/8845/FlowLayoutPanel-TableLayoutPanel-controls-Visual-S
https://www.developer.com/net/net/article.php/11087_3671986_3/Changing-Layout-Dynamically-in-Windows-Forms.htm
I'm currently trying to create a responsive winforms application.
What I try to archive:
I want to create a winforms layout which will have a responsive UI.
What is my problem:
I've added three pictureboxes(Close button / minimize application button / maximize application button) to the first row of the TableLayoutPanel.
Those three pictureboxes are positioned in the top right corner of the form. But the location of those pictureboxes won't change once I click the maximize button. Theyre staying at the exact position which makes them literally centered on the maximized screen.
Screenshot showing it:
What could I do to fix this issue? I appreciate any kind of suggestions and help.
What I have done so far:
Added a TableLayoutPanel which contains 2 Rows.
Added a Panel to the first row containing a pictureBox.
Added 3 more pictureBoxes to the pictureBox which are the buttons shown in the screenshot to close / minimize / maximize the application.
First, a TableLayoutPanel is quite a terrible control. It's hard to work with an has a noticeable performance issue once you get too many columns or rows. I suggest using two regular panels, one with Dock = Top and the other with Dock = Fill instead.
As for your buttons, I would position them inside the top panel, and set their anchor properties to Top and Right.
Further reading:
Control.Dock property.
Control.Anchor property.
You should anchor them to the right of their container. You should probably have a look at this:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.anchor(v=vs.110).aspx
I know there is a way to make spacing equal for controls in the designer view. But is this possible to do it programatically? Because I have a form with multiple buttons and we dont know which buttons will be displayed and which will be hidden at the compile time. So they look uneven when the form is displayed(some with more spacing and some with less spacing). Is there a way to re position them at the run time? Is there an equivalent to doing the Format -> Horizontal Spacing -> Make equal programatically?
Thank you for any help.
You could achieve it using FlowLayoutPanel. Which represents a panel that dynamically lays out its contents horizontally or vertically.
When all the buttons are visible
When button3 is hidden at runtime