I would like to improve my application's interface. Is it possible to add something like this(refer to image below)?:
When you click the name or move the cursor to the name, a pop up box will appear with user's main info. If possible, can you teach me the appropriate tools to use. I don't mind if it is basic tools, so i can make a little similar to the image.
BTW, i'm using visual studio 2013.
Here is an (absolutely minimal) example of a pop-up Panel that takes care of the showing and hiding:
Panel popPanel = new Panel();
private void linkLabel1_MouseEnter(object sender, EventArgs e)
{
popPanel.Parent = linkLabel1.Parent;
popPanel.Location = new Point(linkLabel1.Left - 20, linkLabel1.Top + 10);
//popPanel.displayData(someDataClassFromSender);
popPanel.Show();
popPanel.MouseLeave += (ss, ee) => { popPanel.Hide(); };
}
For the layout and display of the info on the Panel (or some other control) you should create a class PopUpPanel and give it a method to load the data it shall display..
If it is a web application go check out http://bootsnipp.com/snippets/featured/fancy-navbar-login-sign-in-form
Just change the event from click to hover.
And get youserlf a copy of bootstrap http://getbootstrap.com/
Related
This question already has answers here:
How to add buttons dynamically to my form?
(8 answers)
Closed 2 years ago.
I cannot find any methods to add the button to the layout.
I am trying to add the child (button) to the layout, but I can't find any methods to do so.
Source Code:
using System;
using System.Windows.Forms;
namespace WinForms
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Button button = new Button {Height = 100, Width = 100, Text = "Test"};
}
}
}
You open your project in Visual Studio 2019 (not Visual Studio Code, not JetBrains Rider) - free versions for which exist if your context qualifies for the license. If you don't qualify for a free license, you[r workplace] can easily afford a license of some form
You double click Form1 in the solution explorer and then you see something that looks like what the form will look like when you run the program, and you open the controls tool panel and drag a button out of it and drop it onto the form...
But if you want to get into hand-writing the volumes of boring repetitive code to build a UI then you add controls to the Controls collection of other controls, viz:
Form1 f = new Form1();
Button button = new Button {Height = 100, Width = 100, Text = "Test"};
f.Controls.Add(button);
Application.Run(f);
Every Control has a Controls collection to which other Controls can be added (not just things you think of as "things that have child controls, like Panel or GroupBox" - some controls are collections of other controls, like a NumericUpDown is a textbox and a couple of buttons)
For an example of how much code you'll need to write, lay out a reasonable looking UI in the design view and then open the Form1.Designer.cs - you'll see why we do it with the aid of a design tool! :)
Wouldn't it be faster to learn if I didn't use the Designer tool?
IMO, no. That's like saying "wouldn't it be faster to learn if I hand code an SVG in notepad rather than using Inkscape/Gimp to draw the image visually.. or create a PNG by typing the bytes out in a hex editor"
Getting so close to the raw low level means you end up "not being able to see the wood for the trees" and it hinders your learning. For a lengthy discourse on abstractions and why we use them/how they apply to every daily process including learning and operating in life, see the comment trail
You need to add the button to your Form, not to the Main method!
The issue with your code is that it's in the wrong place - actually, it only runs after the form is closed, because Application.Run will run your form in a message loop, allowing UI events to fire.
You can either use the Visual Studio WinForms Designer (if using Visual Studio), or manually add the code after the InitializeComponent() method - so, either right in the constructor, or in any of the Form startup events, such as Load or Shown.
It's likewise very important to add the Button (or any dynamically instantiated control, for that matter) to the Controls collection of the Form - otherwise, your Button won't be displayed:
Button button = new Button {Height = 100, Width = 100, Text = "Test"};
this.Controls.Add(button);
There are certainly use cases for dynamic generation of controls; however, it's very unusual to build out your controls manually before the form even runs - in most cases of dynamic control generation, the form is up and running - the dynamic generation is in response to some user action. I recommend using the designer for general UI layout.
I'm just learning how to make universal apps for windows 10. Most of the tutorials show you how to work with XAML and how to assign functions to elements when you click on them but I couldn't find a way to make a new control appear when I click a button.
I'm making a note taking application. I've designed most of the stuff that I need. Now I want whenever I click a button to create a new textblock where the user can write their note.
//Create a new note when clicking the add button
private void newNoteBtn_Click(object sender, RoutedEventArgs e)
{
TextBox newNote = new TextBox();
newNote.Text = "Enter your text";
}
This is the code that runs when the button is clicked. When I run the application nothing happens. I think I have to put the new textbox in some kind of Grid or something.
Most of the tutorials are really old or mention windows forms and use some sort of this.Controls.Add(newNote); but Visual studio doesn't give me the Controls.Add option. I've also created a <Grid x:Name="notes"></Grid> which I thought I could use as a placeholder for the notes that are being created but I can't access the Grid element through the code.
Container Controls like Grid have Children property so you should use Childern like this:
TextBox newNote = new TextBox();
newNote.Text = "Enter your text";
notes.Childern.Add(newNote);
When defining
<Grid x:Name="notes"></Grid>
in XAML on the page, you be able to use notes as the identifier to access this Grid from the page's code behind:
notes.Children.Add(newNote);
I am new in C# and DevExpress. I'm trying to show another form by clicking a tile in the tileControl group but it doesn't show up. I just right-clicked at the tileControl, clicked view code and manually declared this since this doesn't automatically shows up if you double click a tile.
private void addTile_Click(object sender, EventArgs e)
{
var xForm2 = new XtraForm2();
xForm2.Show();
}
I just right-clicked at the tileControl, clicked view code and manually declared this since this doesn't automatically shows up if you double click a tile.
If I understand this correctly, you did not build your project using the C# code listed above, but only edited the source.
That does not work because what you edit in this way is not being loaded into the app.
Of course, I could be misunderstanding what you wrote.
Here is my form
If I click on "Add" on the first panel I want to create "Strategy1_2" just below the first and shift all others panels down.
If I click again I want to create Strategy1_3 (...)
I know how to create a button but not how to duplicate a entire panel.
Here is my code for a button is it far from this procedure ?
private void addstrat1_i_Click(object sender, EventArgs e)
{
panel3strat.Width += 200;
Button addstrat1_2 = new Button();
addstrat3_2.Size = new Size(210, 41);
addstrat1_2.Location = new Point(31,89);
addstrat1_2.Visible = true;
panel1strat.Controls.Add(addstrat3_2);
}
The best way would be that you create a UserControl for your strategy panel. You can then insert the UserControls to a FlowLayoutPanel. This will resolve your issue with placing controls exactly and to create a copy of some panels.
Be aware that you can run out of resources (e.g. windows handles) when adding to much controls on your form. This can be solved by only showing a certain amount of controls and shifting the data through this "fixed" controls while scrolling.
I recommend having two methods: CreatePanelBlock() that will issue a UserControl that you'll add to your container, and BindPanelWithData(...) that will setup the dependencies.
Remember, you may make your panel as a custom control.
I'm using a winForm. I have 2 custom controls that I want to add dynamically.
The first one is added at the opening of the form. The second one is added when the user clicks a button. Nothing magic here. The problem is that when I instanciate and add the second control, instead of appearing on top of the other one, it appears under.
There must be a way to add the control in a way that will make it fully visible (on top of the rest).
Here is how I create the second control (same way as the first control). I tried using show/hide methods, but this won't change the stack order.
private void lbRappel_Click(object sender, EventArgs e)
{
NoteCallBack noteCallBack = new NoteCallBack("test");
this.Controls.Add(noteCallBack);
noteCallBack.Location = new Point(200, 250);
}
Thank you very much in advance for your help.
Mathieu
You could try the BringToFront control function:
private void lbRappel_Click(object sender, EventArgs e)
{
NoteCallBack noteCallBack = new NoteCallBack("test");
this.Controls.Add(noteCallBack);
noteCallBack.Location = new Point(200, 250);
noteCallBack.BringToFront();
}
Can you create them at design time with the z-order you want, then only make them visible at runtime?