I am trying to create a panel which will have a set of "buttons" on it.
These buttons should have the following behaviour:
Appear similar to a tag (with
rounded edges)
Contain a red
cross to remove the filter/tag from
the panel, similar to the way internet
explorer tabs have an embedded cross to close the individual tab.
allow the user to click
on the tag and respond like a normal
button (as long as the click is not
in the red cross)
Number 1 is no problem, this is just appearance, however, regarding numbers 2 and 3, I am not sure if there is already code out there do to something similar...and I dont really want to reinvent the wheel if I can avoid it!
My question is: Does anyone know if there is something out there in infragistics which will do this simply, or will I need to write this myself by subclassing winform buttons?
Thanks in advance!
Is this new development or maintenance of an existing project?
If it is maintenance, you have a somewhat tougher time ahead. You'll implement a UserControl, probably segmented into two buttons. Use docking to get the behavior as correct as possible. The far right button would contain your cross image; the left (which would need to auto-expand as you resize the control) would contain your primary button behavior. Play with the visual styles until you get them right (EG, removing borders, etc).
If this is new development, and you haven't gotten too far into it, you might consider using Windows Presentation Framework (WPF) instead of WinForms. It will be easier to build the control and get it to look exactly how you want it. WPF includes an extremely powerful control compositing system which allows you to layer multiple controls on top of each other and have them work exactly as you'd expect, and it carries the added advantage of allowing full visual control out-of-the-box.
Either way, this is more work than dropping in an external component ... I've used Infragistics for years, and I can't think of anything they have which is comparable. The closest, but only if you're building an MDI application and these controls are for window navigation, is the Tabbed MDI window management tools -- and there, only the tabs (which replace window title bars) have this behavior.
I don't think that infragistics can do something like this. The UltraButton control can't.
Implementing a own control wouldn't be that hard.
your probably going to have to make a costume control for this type of work.
Related
I am doing my first steps programming a little toolbox in C#.
I want to choose the program to run via a menustrip.
How can I switch all visible textboxes, buttons etc. on the same form? I don't want to open a new form. Do I have to show/hide every element "by hand" or is there a better solution?
I hope you get my problem.
Thanks in advance.
Yes totally understood.
You need a way to navigate between different fragments within your application.
Since these are your first steps and not a legacy app, why aren't you starting with WPF which is the successor of Winforms ? (newer better)
See how can you achieve such functionally in WPF
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/app-development/navigation-overview?view=netframeworkdesktop-4.8
Although the terms are similar and also apply in winforms.
What you want to do is to create all the buttons etc as part of a UserControl. You can then add your custom UserControl to the form. This should allow you to switch the user control for some other control, or change the visibility for the whole user control.
This can also allow you to place multiple user controls side by side or in some other layout.
As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!
There are some programs such as Google Chrome and this:
They have a windows forms border that is different than the default. How do these programs do this and still allow the user to drag the window around? Is it possible in C#?
There are plenty of component suites (DevExpress, Infragistics, Telerik, etc.) doing this but you can do it on your own as well. But prepare to get dirty - really dirty!
Basically you have to catch the windows messages (yes, native!) and handle them properly. To make the form draggable is the easiest thing in this chapter (you just have to tell windows that the mouse is over the titlebar area even if it is not >> see here on CodeProject).
Let me get back to the painting: Don't do it!
There are so many things to handle ...
is your form maximized, minimized, normal state
which of the buttons (min/max/close) are enabled?
is it a tool window or a sizeable one?
is there a help button?
is the form sizeable? if so, you have to draw that border as well ...
... and so many more.
In addition, painting in the non-client-area is not as easy as painting usercontrols with a Graphics object. And even if that does not scare you by now, you might probably find yourself breaking the layouting logic of your forms' controls because the forms' size is the same as its ClientSize.
So, please consider to use DevExpress or any other toolkit. Speaking of DevExpress - I knew there was a free set of their fantastic controls and I'm pretty sure that the XtraForm (which does all the titlebar painting) is included as well.
Save big parts of your life and skip that chapter.
(However, if you're brave enough, check this article to do it anyway).
I would like to create a GUI where the main panel expands him self only to the space available, and then if some of the tools 1 or 2 are activated they appear at the top right side and if other tool is started it would automatically displays below ht visible ones or at top of none is displayed...
And if possible the append function.
I think its possible to do this with a bunch of if statements to re-size the panels everytime something would change the window content but there must be an easy way to do this.
Is something similar to the workflow of visual Studio...
Right now im using Windows Forms but i think its possible to switch to WPF
So what I'm looking for is for tutorials,sites,guides or simple a call to pay attention to some options inside the visual studio himself to help me create what I'm trying to achieve.
Here is a mock up to a better understanding
http://i.stack.imgur.com/0vupi.jpg
P.S the only thing I managed to do is hide and make visible the tool panels, but the space is always occupied in blank, and they appear no at top or bottom but the place where i drop them even if i dock them.
If you're open to third party controls, Telerik makes a fantastic dock control that does exactly what you're looking for.
Another option would be Digital Rune Docking or Windows, which is free for non-commercial use.
EDIT:
So, I ended up making my own basic solution to this problem, and it can be found in my own answer to the question below. Or, here's a link.
Original Post
I'm doing some UI programming for a small .NET application. The application has some collections of items that need to be displayed in a grid sort of format (X columns by Y rows) and the grid elements need to be able to get dragged around to different grid locations, and possibly out of the grid all together.
The most comparable sort of UI design elements I can think of are the jQueryUI Draggables.
Do I have to roll my own or are there components people have already written to act like this? Even better, are there any free components? Or is there an easy way to do this that I just don't know about (don't do a lot of .NET UI programming..)
Also these "grid items" need to be able to include windows form components. The DataRepeater control is close to what I need, except it only supports horizontal or vertical alignments, not grids of items.
Here's a visual example of what I'm looking for:
I tried to stick with a halloween theme here.
Well I rolled my own solution and hosted it on GoogleCode:
draggableitemorderedpanel- A .NET Winforms Component... Kinda like jQuery UI Draggables (not really, maybe someday)
here's a screenshot:
(source: googlecode.com)
and another just resized:
(source: googlecode.com)
Hope this helps someone else out. Also it's super basic and pretty sucks right now but gets the job done.
Anyone that wants project access can have it.
The System.Windows.Forms.TableLayoutPanel control supports dragging and dropping, you just have to handle the right events. You could make your own "GridItem" user control, with the icon, caption, background color, etc displayed on a Panel, and then plop a bunch of them in the tablelayoutpanel, and wire up some event handlers. Here's something similar:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/1cade626-b76d-40c5-9e5a-101cf2a5e412