add pagebar in my form for to change page - c#

I made a simple GUI, in which I would like to add an option where I can switch pages, it is the same page when I open it, I would like a bar where I click and switch pages
namespace POS
{
public partial class Form1 : Form
{
private object gunaLabel_date;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Guna.UI.Lib.ScrollBar.PanelScrollHelper flowphelper ;
gunaLabel_date = DateTime.Now.ToLongDateString();
}
private void gunaVScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
}
private void userControl17_Load(object sender, EventArgs e)
{
}
}
}

Related

wpf how to send string or info on anther page or window or usercontrol

i have big problem visual studio wpf , when i try to send any string it doesn't work
i tried to write public string str { set; get; } This problem has been stuck with it for a long time, I tried a lot to use crooked methods, but the program or project crashes.
im using visual studio wpf c#
thank you for answer
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
Info.Content = "Hello world";
}
private void button2_Click(object sender, RoutedEventArgs e)
{
Frame.Content = new Page1();
}
private void button2_MouseLeave(object sender, MouseEventArgs e)
{
Info.Content = "Label";
}
private void button1_MouseLeave(object sender, MouseEventArgs e)
{
Info.Content = "Label";
}
}
here Page class
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mw = new MainWindow();
mw.Info.Content = "Test Public";
}
}
Update Page1's button1_MouseEnter code to:
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mw = Application.Current.Windows.OfType<MainWindow>().First();
mw.Info.Content = "Test Public";
}
or
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mw = (MainWindow)Application.Current.MainWindow;
mw.Info.Content = "Test Public";
}

Is there a way to make a panel move slowly in Visual Studio using C#?

I have coded a form where a panel moves when a button is clicked to the height of the clicked button. However, I want to make the panel move slowly instead of instantly.
This is the code I have used:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MovePanel(btn1);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void MovePanel(Control c)
{
Panel.Height = c.Height;
Panel.Top = c.Top;
}
private void btn1_Click(object sender, EventArgs e)
{
MovePanel(btn1);
}
private void btn2_Click(object sender, EventArgs e)
{
MovePanel(btn2);
}
private void btn3_Click(object sender, EventArgs e)
{
MovePanel(btn3);
}
}
I would really like to see a timer-based solution from scratch.
In the meantime, you might check out something like dot-net-transitions, available on NuGet.
using Transitions;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
btn1.Click += btn_Click;
btn2.Click += btn_Click;
btn3.Click += btn_Click;
MovePanel(btn1);
}
private void MovePanel(Control c)
{
var t = new Transition(new TransitionType_Linear(500));
t.add(Panel, "Height", c.Height);
t.add(Panel, "Top", c.Top);
t.run();
}
private void btn_Click(object sender, EventArgs e)
{
MovePanel(sender as Control);
}
}

Three buttons in window form opening a same another form

I have three buttons in a window form to open 3 differnet forms, but these are opening same form which should be opened by button1 only.
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Task addnew = new Task();
addnew.Show();
}
private void button2_Click(object sender, EventArgs h)
{
Task History = new Task();
History.Show();
}
private void button3_Click(object sender, EventArgs v)
{
Task Evaluate = new Task();
Evaluate.Show();
}
}
if your form name are Task , History and Evaluate then Initialize your three from in three method
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Task addnew = new Task();
addnew.Show();
}
private void button2_Click(object sender, EventArgs h)
{
History history = new History();
history.Show();
}
private void button3_Click(object sender, EventArgs v)
{
Evaluate evaluate = new Evaluate();
evaluate.Show();
}
}

New coder, trying to make Label invisible on program start

First, pardon my new-ness, I just started coding class recently. Now, upon startup, I want parts of my form (c#) to not be shown, however when I put
NameDisplay.Visible = false;
(NameDisplay being the label I wish to hide) into my Form1.cs it gives me the error of that it is a 'field' being used as a 'type'. How do I correct this, and apply to other object types (buttons, textboxes, etc?)
EDIT 1-
Code- as it stands
namespace ATM
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Label NameDisplay;
NameDisplay.Visible = false;
private void Form1_Load(object sender, EventArgs e)
{
}
private void StartButton_Click(object sender, EventArgs e)
{
}
private void NameDisplay_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
Remove Label NameDisplay;, and place NameDisplay.Visible = false; into your FormLoad event.
The loading of a form is an event just like clicking a button, and will execute the code like so.
Also, when I hide labels, I use .Hide(), but I believe that only works on WinForms.
Hope this helps!
You need to drag and drop the Label on the form and object will be created and initialized automatically in InitializeComponent.
In the form constructor (after InitializeComponent function) or Form_Load event, you may set the visibility to false
For example:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
NameDisplay.Visible = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void StartButton_Click(object sender, EventArgs e)
{
}
private void NameDisplay_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}

Retrieve data from one form and use it in another form

Alrighty. Here is my problem. I have just about everything done. I just need to take input from the form, and then use it in an algorithm in the second form. I have everything else written up, I just need to know how to connect the 2 so I can write up the last of the code. I've done some research, but none of it seems to go with what I'm trying to do.
Here is the main form.
namespace Airplanes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
}
private void Arrival_Click(object sender, EventArgs e)
{
ArrivalForm newForm;
newForm = new ArrivalForm();
newForm.ShowDialog();
}
private void Fuel_Click(object sender, EventArgs e)
{
Fuelform newForm2;
newForm2 = new Fuelform();
newForm2.ShowDialog();
}
private void Status_Click(object sender, EventArgs e)
{
}
private void Items_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void NameBox_TextChanged(object sender, EventArgs e)
{
}
private void FuelBox_TextChanged(object sender, EventArgs e)
{
}
private void GateBox_TextChanged(object sender, EventArgs e)
{
}
private void Singlebutton_CheckedChanged(object sender, EventArgs e)
{
}
private void PrivateButton_CheckedChanged(object sender, EventArgs e)
{
}
private void CommercialButton_CheckedChanged(object sender, EventArgs e)
{
}
}
}
And here is the form I'm trying to connect to the main form.
namespace Airplanes
{
public partial class Fuelform : Form
{
public Fuelform()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Fuelform_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Thanks in advance for any answers.
There are a couple of ways...the easiest would probably be to pass the data in through the constructor of your new form.
FuelForm newForm2 = new FuelForm(myData);
And then change the constructor for your FuelForm:
public FuelForm(int myData) // or whatever data type you need
{
// Deal with myData
}
In Source form
destinationForm df = new destinationForm ();
df .myValue= "My Value";
df .ShowDialog();
in Destination Form
private string destVariable;
public string myValue
{
get { return destVariable; }
set { destVariable= value; }
}
then you can use destVariable everywhere in destination form

Categories