I have a chart with multiple chart areas and I want to have a listview where the user checks different signals, that are being plotted in the areas.
Since I want some signals to be displayed in more than one chart areas, I need the listview to reset every time the user selects a different chart Area.
To achieve this I think it is a good idea to create a new listview every time the user selects another chart area and bring the new to front.
My question is , how can I create multiple listviews at the exact same location, and also if someone has a better idea to this.
As you know, you can define the listview in code and do all the styling by hand or you can create a customControl for that.
But then, when the load event of your main form is fired, you create all the listview/customListViewObjects that you need and place them in the same location with the same size by setting their Location and Size property. Finally, you can use BrintToFront() on the required listview when an area is selected.
There are some other ways, but they aren't beautiful in winforms.
A) you can create a tab control with N tabs, then place a listview in each tab and set the tabControl style to the tab header/title is not shown. But as far as I remember, the tabControl will add a border frame that your cannot get rid of.
B) If you don't have many areas and its number is not going to change, you can create the listviews manually in your form editor, and place them wherever in your form (with the appropriate parent, of course). Then in your load event, you can set their location and size properties to the one you need. This is kind of ugly and you may see the controls moving when the form is loaded if you are not careful.
On the other hand, you can just have one listview and then, when the area is clicked you can reload all its child controls for the different signals.
Related
I currently have a windows form that I am using as a "holder" for many panels. All of these panels are being used like pages, so say I have a default panel, a details panel etc. They all cover the exact same area and i am using a top menu to have buttons to show/hide the correct panel.
The problem I have with this is that I cannot select one panel and edit it or simply bring it to the front to edit it in "design" mode, I currently have to keep sending the top panel to the back until I get the one I need. This is okay now, but eventually my program will have over 20 panel type pages, and this will get tedious.
Is there a better way to manage this, or is there an easier way than using panels?
All these panels are used like pages
Above line in your question suggests that you should be using TabPage instead of Panels.
Therefore, You can use a TabControl, and add TabPage to it both at design time as well as at runtime easily, and add controls of your choice to the different TabPage(s).
According to wikipedia:-
Tab is one that allows multiple documents to be contained within a single window, using tabs as a navigational widget for switching between sets of documents. which is essentially what you want to do.
As shown in the picture
You can then use Button to switch b/w different TabPage or show/hide TabPage.
It will not only solve your problem of designing at design time, it will also provide a "clean" user interface. Hope that helps!
Check this:-
http://en.wikipedia.org/wiki/Tab_(GUI)
Use a TabControl instead. It will allow you to switch an active panel also in design time.
If you want to keep the panel method there is a way of working around the problem of one panel becoming an element of another. Drag the panel outside the boundary of the other panel (so that it is no longer an element of the other panel) and then re-position it using the arrow keys on your keyboard (i.e. not by dragging it into position over the other panel using the mouse). It seems like the panel will only become an element of another panel if it is dragged into position over the top of another panel using the mouse.
First of all, here's some concept art for how this custom list control must look:
http://img816.imageshack.us/img816/1088/customlistctrl.png
Each list item is fairly complex and turns into an "edit interface" when the mouse hovers over it. I also have PNG image files for every skinning detail of this thing, including the scroll bar.
What is the best approach to get started implementing this? Would I create a custom control and simply render all of this in GDI?
Could I make the list control a transparent clip region with a scroll bar? For the individual list items, would I simply use a textured panel as the backdrop for each item and place existing .NET forms (like combo boxes, buttons, edit fields, etc) as children of that?
I've never had to create something this detailed before.
If you want your control to look exactly like the given picture (which is nice), you will end up drawing much of it, if not all of it, yourself. One possibility is to subclass each control being used and override the OnPaint method to do your custom drawing. This assumes a design where everything in your picture is an individual control.
I myself might make each row a separate UserControl-derived class, perhaps with an internal constructor so users of your control can't create the row directly. Within your SkinnedListRow class (or whatever name), you could have each of the subcontrols. By the looks of things, the row contains three controls that display numbers and one that displays any kind of text.
For the editing portion, derive another UserControl that contains all the controls you picture. Both the display controls and the editing control are owned by the SkinnedListRow from above, so it knows how to load data from one set into another.
You have a good amount of work in front of you, but your idea looks nice. Good luck.
hii
I am a fresher in the c # so i want to know how to resize the datagrid(any other control)aith respect to the form size.
I just added one datagrid in the form then what i have to do?please help me...from the very basic please
For a dynamic layout that scales with your form size you have various options (depending on the complexity of your layout).
The first ones are
Anchoring
Docking.
But you can also work with advanced container controls like
TableLayoutPanel
FlowLayoutPanel
SplitContainer.
Some more informations i already post in an older question.
If you have more concrete problems about how to solve a specific layout problem you should post a new question with your exact problem.
But at a first tip i can say that it is never necessary to use the Resize event and do some size changes on yourself. There is always a solution that can be solved with the above elements.
You have to ways of dong it:
Using a Dock. It works fine and is very easy to use but its limit is that you can stick it to a one side of parent container. So if you want to streach control only in width you will fail.
Using Anchor. It require more configuration but you can specify all four(top, right, down, bottom option separably.
Regards
Szymon
Go to the properties window and scroll down to "Docking" and choose to dock the control in the parent container. This will give you various options about how you want the control to dock. You should put some containers in there of some sort, maybe, if you've got buttons or things you'd like to have show up above/below/next to the grid. Also, if your grid goes behind your other controls, select the control and bring it to the front.
edit:
You need some containers in which to put your buttons / drop-downs. You could use a flow-layout panel (which wouldn't resize its child controls), or you could use a plain panel or the table-layout panel. The table one will let you dock your child controls within each cell of the table, and you can set your columns & rows to auto-size to a percentage of the entire table width. That way everything will autosize accordingly.
I need to build a WPF control that looks somehow similar to this:
alt text http://img251.imageshack.us/img251/6857/circle.png
Where each color should be clickable and resizable (or selectable).
This control will be used to set modes on the hours of a day.
I've thought about making 24 buttons that would be arranged in a circle:
alt text http://img684.imageshack.us/img684/2184/buttonsk.png
Another idea was to draw a complete circle and calculate user mouse click's position for the selection and draw several circles to represent the data.
Any other/better ideas on how to build this?
(please excuse my poor drawing).
I think you would get odd edge-effects with multiple overlapping or touching controls. So I would make a single custom control to do this. It would convert the mouse position on button down to a slice, and then do the appropriate action.
With a single control, you could also come up with a rational way of dealing with keyboard input and for showing selection and allowing for multi-select behavior.
It sounds like you want a customized ListBox (multiple items that are selectable/clickable). For the layout you would want to use some type of RadialPanel as the ItemsPanel. You probably also need to change the ItemContainerStyle to make your ListBoxItems look like what you have above, probably with some triggers to change colors based on selection state. Depending on what behavior you need from your items you may need to create custom ListBox/ListBoxItem derived custom controls but in a lot of cases the built-in behavior will get you a long way. To reuse it as a single unit you could wrap up the ListBox with its 24 hour items and customized templates in a UserControl and expose the selection data in whatever form you need as a Dependency Property (like an IEnumerable of the data items representing the selected hours).
Does that help you get started?
I have a user control that has:
a) a buttons panel at the top (it always has to be visible)
b) a panel with controls that are dynamically added and re-sized at run-time. The controls can be many, so the panel has to be scrollable.
This user control will be hosted in a form, with the following requirements:
a) The initial size of the form will try to fit in maximum part of the dynamic content.
b) On changing the form size, the control has to be re-sized accordingly.
I had played with various anchoring, docking, and auto-sizing and I don't quite get it working in the way I want to. Sometimes, it is the scrolling that messes up, sometimes it is something else.
What combination of anchoring, docking, and auto-sizing of the panels, usercontrol, form should work best to achieve the desired outcome?
I succeeded to meet the requirements. Here is my solution:
The dynamic panel is anchored to the top and the bottom of the control. It does not AutoSize, it manually changes its MaximumSize and PreferredSize after change in the contents.
The form hosts the form using:
cntrl.AutoSize = true;
cntrl.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
cntrl.Dock = System.Windows.Forms.DockStyle.Fill;
The form subscribes to a custom control's event that notifies for the preferredHeight and it changes its own Height accordingly.
I'd go with a table layout panel. You can specify two rows by one column with the exact size for the buttons at the top and fill the rest with the bottom. Then put put either a normal panel or a flowlayoutpanel for the dynamic content in that area.
Without knowing the specifics of your problem I find multiple fill docked split containers with one fixed panel and/or a fixed slider usually creates a really handy resizing experience. You can also collapse panels very effectively too.