NoInternet
New member
- Joined
- Apr 23, 2020
- Messages
- 3
- Programming Experience
- 3-5
I have recently installed Visual Studio Code on my Raspberry Pi 3B+ (small pocket-computer) and I have also installed Mono to compile and run C# applications. I've made a simple window that has buttons and textboxes but I can't change their properties in the "clicked" function. There is no Visual Studio for Linux and if there is one, it would require too much resources and the Pi won't handle it. Is there any way of passing another variable alongside with object sender and EventArgs e?
My Code:
using System;
using System.Drawing;
using System.Windows.Forms;
public class Program
{
[STAThread]
private static void clicked(object sender, EventArgs e){
password = textbox.Text;
if(password == "mypassword"){
stateLabel.Text = "Password is correct";
}else{
stateLabel.Text = "Password is incorrect";
}
}
public static void Main()
{
var window = new Form();
window.Text = "Login";
window.Height = 130;
window.Width = 365;
TextBox textbox = new TextBox();
Label passwordLabel = new Label();
Button passwordButton = new Button();
Label stateLabel = new Label();
stateLabel.Text = "Please enter your password";
passwordLabel.Text = "Password";
passwordButton.Text = "Login";
passwordLabel.Location = new Point(25, 30);
textbox.Location = new Point(125, 25);
passwordButton.Location = new Point(260, 25);
stateLabel.Location = new Point(125, 60);
passwordButton.Click += new System.EventHandler(clicked);
window.Controls.Add(textbox);
window.Controls.Add(passwordLabel);
window.Controls.Add(passwordButton);
window.Controls.Add(stateLabel);
Application.Run(window);
}
}