delegate c# to share data between forms - c#

i have this assignement when i need to create a winform of all classes that i ve implementedalready did form add but got issues in my list form cant access list of borrowers from form add1
here is my form list1.cs
namespace TP.A {
public partial class list1 : Form{
private Button Exit;
private GestionEmprunteur _gestionEmprunteur;
public list1()
{
_gestionEmprunteur = new GestionEmprunteur();
InitializeComponent_D();
InitializeDataGridView();
// Abonnement à l'événement OnAddEmprunteur de l'objet add1
add1 addForm = new add1();
addForm.OnAddEmprunteur += AddEmprunteur;
}
private DataGridView dgvBorrowers;
private void InitializeDataGridView()
{
{
//create DataGridView to display borrowers
dgvBorrowers = new DataGridView();
dgvBorrowers.Location = new Point(100,200);
dgvBorrowers.Size = new Size(798, 450);
dgvBorrowers.AutoGenerateColumns = true;
dgvBorrowers.DataSource = _gestionEmprunteur.Lister2();
this.Controls.Add(dgvBorrowers);
}
}
private void AddEmprunteur(Emprunteur emprunteur)
{
_gestionEmprunteur.AddEmprunteur(emprunteur);
dgvBorrowers.DataSource = _gestionEmprunteur.Lister2();
}
private void InitializeComponent_D()
{
// DESIGN1.ApplyDesign(this);
//create submit button
Exit = new Button();
Exit.Text = "Exit";
Exit.Font = new Font("Times New Roman", 12, FontStyle.Regular);
Exit.Location = new Point((this.Width - Exit.Width) / 2, 500);
Exit.Size = new Size(100, 50);
Exit.Click += new EventHandler(exit_Click);
this.Controls.Add(Exit);
Exit.BringToFront();
Exit.RightToLeft = RightToLeft.Yes;
}
private void exit_Click(object? sender, EventArgs e)
{
this.Close();
} }}
here is my form add1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Validation.services;
using serie2.Validation.services;
using TP.main;
using System.Windows.Forms;
namespace TP.A
{
public partial class add1 : Form
{
public delegate void AddEmprunteurHandler(Emprunteur emprunteur);
public event AddEmprunteurHandler OnAddEmprunteur;
private Emprunteur emprunteur;
private GestionEmprunteur _gestionEmprunteur;
private TextBox _nameTextBox;
private TextBox _firstNameTextBox;
private Button _submitButton;
private Button _cancelButton;
private Label _nameLabel;
private Label _loginLabel;
private Label _firstNameLabel;
private List<Emprunteur> _emprunteurs;
public add1()
{
_emprunteurs = new List<Emprunteur>();
_gestionEmprunteur = new GestionEmprunteur();
InitializeComponent(this);
}
private void InitializeComponent( Form form)
{
DESIGN1.ApplyDesign(this);
//create label for name
Label loginLabel = new Label();
loginLabel.Text = "Login :";
loginLabel.Left = 0;
loginLabel.ForeColor = Color.White;
loginLabel.BackColor = Color.Black;
loginLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
loginLabel.Location = new Point((form.Width - loginLabel.Width) / 2, 100);
loginLabel.Font = new Font("Andalus", 22, FontStyle.Bold);
loginLabel.AutoSize = true;
// nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
this.Controls.Add(loginLabel);
loginLabel.BringToFront();
//create label for name
Label nameLabel = new Label();
nameLabel.Text = "Name:";
nameLabel.Left = 0 ;
nameLabel.ForeColor = Color.White;
nameLabel.BackColor = Color.Black;
nameLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
nameLabel.Font = new Font("Times New Roman",16 ,FontStyle.Bold);
nameLabel.AutoSize = true;
// nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
this.Controls.Add(nameLabel);
nameLabel.BringToFront();
//create textbox for name
_nameTextBox = new TextBox();
// _nameTextBox.Size = new Size(150, 30);
_nameTextBox.Location = new Point((form.Width - _nameTextBox.Width) / 2, 300);
_nameTextBox.Size = new Size(150, 25);
form.Controls.Add(_nameTextBox);
_nameTextBox.BringToFront();
//create label for first name
Label firstNameLabel = new Label();
firstNameLabel.Text = "First Name:";
firstNameLabel.Left = 0;
firstNameLabel.ForeColor = Color.White;
firstNameLabel.BackColor = Color.Black;
firstNameLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
firstNameLabel.Location = new Point((form.Width - firstNameLabel.Width) / 2, 350);
firstNameLabel.Font = new Font("Times New Roman", 16, FontStyle.Bold);
firstNameLabel.AutoSize = true;
this.Controls.Add(firstNameLabel);
firstNameLabel.BringToFront();
//create textbox for first name
_firstNameTextBox = new TextBox();
_firstNameTextBox.Location = new Point((form.Width - _firstNameTextBox.Width) / 2, 400);
_firstNameTextBox.Size = new Size(150, 25);
form.Controls.Add(_firstNameTextBox);
_firstNameTextBox.BringToFront();
//create submit button
_submitButton = new Button();
_submitButton.Text = "Submit";
_submitButton.Font = new Font("Times New Roman", 12, FontStyle.Regular);
_submitButton.Location = new Point((form.Width - _submitButton.Width) / 2, 500);
_submitButton.Size = new Size(100, 50);
_submitButton.Click += new EventHandler(SubmitButton_Click);
form.Controls.Add(_submitButton);
_submitButton.BringToFront();
_submitButton.RightToLeft= RightToLeft.Yes;
//create cancel button
_cancelButton = new Button();
_cancelButton.Text = "Cancel";
_cancelButton.Font = new Font("Times New Roman", 12, FontStyle.Regular);
_cancelButton.Location = new Point((form.Width - _submitButton.Width) / 180, 500);
_cancelButton.Size = new Size(100, 50);
_cancelButton.Click += new EventHandler(cancel_Click);
form.Controls.Add(_cancelButton);
_cancelButton.BringToFront();
}
private void cancel_Click(object? sender, EventArgs e)
{
this.Close();
}
private void SubmitButton_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(_nameTextBox.Text) && !string.IsNullOrWhiteSpace(_firstNameTextBox.Text))
{
Emprunteur emp = new Emprunteur { Nom = _nameTextBox.Text, Prenom = _firstNameTextBox.Text };
bool success = _gestionEmprunteur.AddEmprunteur(emp);
// Appel de l'événement OnAddEmprunteur
OnAddEmprunteur?.Invoke(emp);
if (success)
{
MessageBox.Show("Borrower added successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
_nameTextBox.Text = "";
_firstNameTextBox.Text = "";
}
else
{
MessageBox.Show("An error occurred while adding the borrower.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
_gestionEmprunteur.Lister();
}
else
{
MessageBox.Show("Please enter a name and first name for the borrower.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
HERE ARE THE MODICATION THAT I UNCLUDED i want to share data of datagrid from my form add1.cs to my form list1.cs i added a datagrid in my form1 to ensure that my data are displayed correctly
but m facing issues to connect both forms
public partial class add1 : Form
{
private Emprunteur emprunteur;
static GestionEmprunteur _gestionEmprunteur;
private TextBox _nameTextBox;
private TextBox _firstNameTextBox;
private Button _submitButton;
private Button _cancelButton;
private Label _nameLabel;
private Label _loginLabel;
private Label _firstNameLabel;
static List<Emprunteur> _emprunteurs;
private DataGridView dgvBorrowers;
public add1()
{
dgvBorrowers = new DataGridView();
dgvBorrowers.Location = new Point(40, 190);
dgvBorrowers.Size = new Size(450, 300);
dgvBorrowers.AutoGenerateColumns = true;
this.Controls.Add(dgvBorrowers);
_emprunteurs = new List<Emprunteur>();
_gestionEmprunteur = new GestionEmprunteur();
InitializeComponent(this);
}
private void InitializeComponent(Form form)
{
DESIGN1.ApplyDesign(this);
//create label for name
Label loginLabel = new Label();
loginLabel.Text = "Login :";
loginLabel.Left = 0;
loginLabel.ForeColor = Color.White;
loginLabel.BackColor = Color.Black;
loginLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
loginLabel.Location = new Point((form.Width - loginLabel.Width) / 2, 100);
loginLabel.Font = new Font("Andalus", 22, FontStyle.Bold);
loginLabel.AutoSize = true;
// nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
this.Controls.Add(loginLabel);
loginLabel.BringToFront();
//create label for name
Label nameLabel = new Label();
nameLabel.Text = "Name:";
nameLabel.Left = 0;
nameLabel.ForeColor = Color.White;
nameLabel.BackColor = Color.Black;
nameLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
nameLabel.Font = new Font("Times New Roman", 16, FontStyle.Bold);
nameLabel.AutoSize = true;
// nameLabel.Location = new Point((form.Width - nameLabel.Width) / 2, 250);
this.Controls.Add(nameLabel);
nameLabel.BringToFront();
//create textbox for name
_nameTextBox = new TextBox();
// _nameTextBox.Size = new Size(150, 30);
_nameTextBox.Location = new Point((form.Width - _nameTextBox.Width) / 2, 300);
_nameTextBox.Size = new Size(150, 25);
form.Controls.Add(_nameTextBox);
_nameTextBox.BringToFront();
//create label for first name
Label firstNameLabel = new Label();
firstNameLabel.Text = "First Name:";
firstNameLabel.Left = 0;
firstNameLabel.ForeColor = Color.White;
firstNameLabel.BackColor = Color.Black;
firstNameLabel.BackColor = Color.FromArgb(128, 0, 0, 0);
firstNameLabel.Location = new Point((form.Width - firstNameLabel.Width) / 2, 350);
firstNameLabel.Font = new Font("Times New Roman", 16, FontStyle.Bold);
firstNameLabel.AutoSize = true;
this.Controls.Add(firstNameLabel);
firstNameLabel.BringToFront();
//create textbox for first name
_firstNameTextBox = new TextBox();
_firstNameTextBox.Location = new Point((form.Width - _firstNameTextBox.Width) / 2, 400);
_firstNameTextBox.Size = new Size(150, 25);
form.Controls.Add(_firstNameTextBox);
_firstNameTextBox.BringToFront();
//create submit button
_submitButton = new Button();
_submitButton.Text = "Submit";
_submitButton.Font = new Font("Times New Roman", 12, FontStyle.Regular);
_submitButton.Location = new Point((form.Width - _submitButton.Width) / 2, 500);
_submitButton.Size = new Size(100, 50);
_submitButton.Click += new EventHandler(SubmitButton_Click);
form.Controls.Add(_submitButton);
_submitButton.BringToFront();
_submitButton.RightToLeft = RightToLeft.Yes;
//create cancel button
_cancelButton = new Button();
_cancelButton.Text = "Cancel";
_cancelButton.Font = new Font("Times New Roman", 12, FontStyle.Regular);
_cancelButton.Location = new Point((form.Width - _submitButton.Width) / 180, 500);
_cancelButton.Size = new Size(100, 50);
_cancelButton.Click += new EventHandler(cancel_Click);
form.Controls.Add(_cancelButton);
_cancelButton.BringToFront();
}
private void cancel_Click(object? sender, EventArgs e)
{
this.Close();
}
private void SubmitButton_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(_nameTextBox.Text) && !string.IsNullOrWhiteSpace(_firstNameTextBox.Text))
{
Emprunteur emp = new Emprunteur(_nameTextBox.Text, _firstNameTextBox.Text);
bool success = _gestionEmprunteur.AddEmprunteur(emp);
if (success)
{
MessageBox.Show("Borrower added successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgvBorrowers.DataSource = _gestionEmprunteur._emprunteurs;
_nameTextBox.Text = "";
_firstNameTextBox.Text = "";
}
else
{
MessageBox.Show("An error occurred while adding the borrower.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Please enter a name and first name for the borrower.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public list1()
{
_gestionEmprunteur = new GestionEmprunteur();
InitializeComponent_D();
InitializeDataGridView();
}
private void InitializeDataGridView()
{
dgvBorrowers = new DataGridView();
dgvBorrowers.Location = new Point(100, 200);
dgvBorrowers.Size = new Size(798, 450);
dgvBorrowers.AutoGenerateColumns = true;
dgvBorrowers.DataSource = _gestionEmprunteur._emprunteurs;
this.Controls.Add(dgvBorrowers);
}

Related

Controls.Find not working within specific if-statement?

I´m stuck on a problem using controls.find and I can´t find the error.
I´m creating a loginform using different panels.
Panels are created as follows:
public Panel CreatePanel()
{
Panel login = new Panel();
TextBox Login_UsernameTB = new TextBox();
TextBox Login_PasswordTB = new TextBox();
Label label1 = new Label();
Label label2 = new Label();
Label loginstatus = new Label();
Button Login_Loginbtn = new Button();
Button Login_Registerbtn = new Button();
PictureBox Login_Logo = new PictureBox();
PictureBox Login_ECard = new PictureBox();
//creatingPanel
login.Location = new Point(0, 0);
login.Name = "Login";
login.Size = new Size(1000, 400);
//locations
Login_ECard.Location = new Point(500, 250);
Login_ECard.SizeMode = PictureBoxSizeMode.StretchImage;
Login_ECard.Image = PatientSimulator.Properties.Resources.Ecard;
Login_ECard.Name = "Login_Ecard";
Login_Logo.Location = new Point(148, 12);
Login_Logo.SizeMode = PictureBoxSizeMode.StretchImage;
Login_Logo.Image = PatientSimulator.Properties.Resources.Logo;
Login_Logo.Name = "Login_Logo";
label1.Location = new Point(31, 200);
label1.Size = new Size(58, 13);
label1.Text = "Username:";
label1.Name = "label1";
label2.Location = new Point(31, 244);
label2.Size = new Size(56, 13);
label2.Text = "Password:";
label2.Name = "label2";
Login_UsernameTB.Location = new Point(148, 197);
Login_UsernameTB.Size = new Size(359, 20);
Login_UsernameTB.Text = "Testfirma1";
Login_UsernameTB.Name = "Login_UsernameTB";
Login_PasswordTB.Location = new Point(148, 241);
Login_PasswordTB.Size = new Size(359, 20);
Login_PasswordTB.Text = "Hallo1234#";
Login_PasswordTB.PasswordChar = '*';
Login_PasswordTB.Name = "Login_PasswordTB";
Login_Loginbtn.Location = new Point(432, 334);
Login_Loginbtn.Size = new Size(75, 23);
Login_Loginbtn.Text = "Login";
Login_Loginbtn.Click += Login_Loginbtn_Click;
loginstatus.Location = new Point(323, 360);
loginstatus.Size = new Size(300, 20);
loginstatus.Text = "";
loginstatus.Name = "loginstatus";
Login_Registerbtn.Location = new Point(323, 334);
Login_Registerbtn.Size = new Size(75, 23);
Login_Registerbtn.Text = "Register";
Login_Registerbtn.Click += Login_Registerbtn_Click;
login.Controls.Add(Login_ECard);
login.Controls.Add(Login_Logo);
login.Controls.Add(label1);
login.Controls.Add(label2);
login.Controls.Add(Login_UsernameTB);
login.Controls.Add(Login_PasswordTB);
login.Controls.Add(Login_Loginbtn);
login.Controls.Add(Login_Registerbtn);
login.Controls.Add(loginstatus);
return login;
}
In Form_load:
Panel login = CreatePanel();
login.Visible = true;
Controls.Add(login);
When I start the application, everything is displayed. if I type some text into systemstatus.text isn't gets displayed.
When doing a check if the entered password & username are correct, the strange stuff happens.
private void Login_Loginbtn_Click(object sender, EventArgs e)
{
Patient.DBAccess db = new Patient.DBAccess();
Sha256 sha = new Sha256();
string username = login.Controls.Find("Login_UsernameTB", true)[0].Text;
string userpw = login.Controls.Find("Login_PasswordTB", true)[0].Text;
Patient.DatabaseRequestInterface.UserInterface user = new Patient.DatabaseRequestInterface.UserInterface();
user.Username = username;
if (db.IsUserExisting(user)){
user = db.ReadUserPassword(user);
string salt = Encoding.ASCII.GetString(user.PasswordSalt);
byte[] pw = sha.GetSha256(userpw, salt);
if (pw.SequenceEqual(user.PasswordHash))
{
//Programm starten
//token generieren
Patient.DatabaseRequestInterface.UserInterface useri = db.ReadFullUser(user);
UserAuthentificationToken = new UserInfo(useri.Username, useri.Uuid, DateTime.Now);
LoginSuccessEvent?.Invoke(this, new EventArgs());
login.Controls.Find("loginstatus", true)[0].Text = "Login successfull";
this.Close();
}
else
{
MessageBox.Show("Login failed, Username and/or password incorrect");
}
}
else
{
MessageBox.Show("Falscher User oder Passwort");
//Controls.Find("Login_StatusL", true)[0].Text = "Login failed, Username and/or password incorrect!";
}
}
The first 2 times I use controls.find it works, I get the strings entered by the users at the corresponding TextBoxes. When I try to change loginstatus, I get a System.IndexOutOfRangeException. My interpretation of the exception is, that there was no loginstatus found. And I don´t understand why. (the other 2 elements can´t be found within the if as well)
Can anyone help?
the controls.find("string",true)[0].Text = "XXX" works, I use it a lot at another part of the application
Any ideas?
Thanks in advance,
David
You miss the Name property in your code and Controls.Find strictly work on Name
Login_UsernameTB.Name = "Login_UsernameTB";
So your Code should be something like this:
public Panel CreatePanel()
{
Panel login = new Panel();
login.Size = new Size(900, 900);
TextBox Login_UsernameTB = new TextBox();
Login_UsernameTB.Name = "Login_UsernameTB";
Login_UsernameTB.Location = new Point(50, 50);
Login_UsernameTB.Text = "Username here";
TextBox Login_PasswordTB = new TextBox();
Login_PasswordTB.Name = "Login_PasswordTB";
Login_PasswordTB.Location = new Point(150, 50);
Login_PasswordTB.Text = "password here";
//stuff is asigned to TBs...
Label loginstatus = new Label();
loginstatus.Location = new Point(150, 150);
loginstatus.Size = new Size(300, 20);
loginstatus.Text = "";
loginstatus.Name = "loginstatus";
login.Controls.Add(Login_UsernameTB);
login.Controls.Add(Login_PasswordTB);
login.Controls.Add(loginstatus);
return login;
}
Also, the login should be class level but not defined inside the Form_Load
like this :
public partial class Form1 : Form
{
Panel login;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
login = CreatePanel();
login.Visible = true;
Controls.Add(login);
}
.....
I have tested it and works fine.
My test code is
using System;
using System.Drawing;
using System.Windows.Forms;
namespace SackOverflow
{
public partial class Form1 : Form
{
Panel login;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
login = CreatePanel();
login.Visible = true;
Controls.Add(login);
}
public Panel CreatePanel()
{
Panel login = new Panel();
login.Size = new Size(900, 900);
TextBox Login_UsernameTB = new TextBox();
Login_UsernameTB.Name = "Login_UsernameTB";
Login_UsernameTB.Location = new Point(50, 50);
Login_UsernameTB.Text = "Username";
TextBox Login_PasswordTB = new TextBox();
Login_PasswordTB.Name = "Login_PasswordTB";
Login_PasswordTB.Location = new Point(150, 50);
Login_PasswordTB.Text = "password";
//stuff is asigned to TBs...
Label loginstatus = new Label();
loginstatus.Location = new Point(150, 150);
loginstatus.Size = new Size(300, 20);
loginstatus.Text = "";
loginstatus.Name = "loginstatus";
login.Controls.Add(Login_UsernameTB);
login.Controls.Add(Login_PasswordTB);
login.Controls.Add(loginstatus);
return login;
}
private void button1_Click(object sender, EventArgs e)
{
if (true)
{
string username = login.Controls.Find("Login_UsernameTB", true)[0].Text;
string userpw = login.Controls.Find("Login_PasswordTB", true)[0].Text;
//UserInterface user = //some database stuff to get the password saved by the user
if ("123" == userpw)
{
login.Controls.Find("loginstatus", true)[0].Text = "Logging in";
Login();
}
else
{
login.Controls.Find("loginstatus", true)[0].Text = "Error";
}
}
}
private void Login()
{
MessageBox.Show("Login");
}
}
}
Result is:
I receive the message box MessageBox.Show("Login"); shown and Loginstatus is shown too.

Why Showing empty windows form not showing any controls in c# project

I designed some Windows form a few days back. After a few days, all controls have disappeared from the form. It seems just like a new blank form. This form is the startup form and it is there in the Program.cs file. Also, I've not edited the designer.cs file manually.
here is my FrmMain.cs code
public partial class FrmMain : Form
{
private bool isCollapsed=true;
public FrmMain()
{
InitializeComponent();
GetDateAndTime();
sidePanel.Top = btnHome.Top;
}
private void GetDateAndTime()
{
try {
timer1.Start();
lblTme.Text = DateTime.Now.ToLongTimeString();
lblDate.Text = DateTime.Now.ToLongDateString();
}
catch (Exception e) {
Clipboard.SetText(e.Message);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
lblTme.Text = DateTime.Now.ToLongTimeString();
timer1.Start();
}
private void btnSettings_Click(object sender, EventArgs e)
{
sidePanel.Top = panelCollap.Top;
timer2.Start();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (isCollapsed)
{
panelCollap.Height += 10;
if (panelCollap.Size == panelCollap.MaximumSize) {
timer2.Stop();
isCollapsed = false;
}
}
else
{
panelCollap.Height -= 10;
if (panelCollap.Size == panelCollap.MinimumSize)
{
timer2.Stop();
isCollapsed = true;
}
}
}
}
Here is the Designer.cs
partial class FrmMain
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.btnHome = new System.Windows.Forms.Button();
this.btnMasterFiles = new System.Windows.Forms.Button();
this.btnEmplyeeCenter = new System.Windows.Forms.Button();
this.btnPayroll = new System.Windows.Forms.Button();
this.btnAttendence = new System.Windows.Forms.Button();
this.btnLeave = new System.Windows.Forms.Button();
this.btnPerformance = new System.Windows.Forms.Button();
this.btnNoticeBoard = new System.Windows.Forms.Button();
this.panelCollap = new System.Windows.Forms.Panel();
this.btnUserSetup = new System.Windows.Forms.Button();
this.btnComanySetup = new System.Windows.Forms.Button();
this.btnSettings = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.lblDate = new System.Windows.Forms.Label();
this.lblTme = new System.Windows.Forms.Label();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.hmeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.masterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.employeeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.payrllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.attendenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.leaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.performanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noticeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label();
this.sidePanel = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panelCollap.SuspendLayout();
this.panel1.SuspendLayout();
this.panel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.flowLayoutPanel1.Controls.Add(this.pictureBox1);
this.flowLayoutPanel1.Controls.Add(this.btnHome);
this.flowLayoutPanel1.Controls.Add(this.btnMasterFiles);
this.flowLayoutPanel1.Controls.Add(this.btnEmplyeeCenter);
this.flowLayoutPanel1.Controls.Add(this.btnPayroll);
this.flowLayoutPanel1.Controls.Add(this.btnAttendence);
this.flowLayoutPanel1.Controls.Add(this.btnLeave);
this.flowLayoutPanel1.Controls.Add(this.btnPerformance);
this.flowLayoutPanel1.Controls.Add(this.btnNoticeBoard);
this.flowLayoutPanel1.Controls.Add(this.panelCollap);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Left;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(234, 902);
this.flowLayoutPanel1.TabIndex = 0;
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(28, 3);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(28, 3, 3, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(174, 134);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 3;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// btnHome
//
this.btnHome.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnHome.FlatAppearance.BorderSize = 0;
this.btnHome.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnHome.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnHome.ForeColor = System.Drawing.Color.White;
this.btnHome.Image = ((System.Drawing.Image)(resources.GetObject("btnHome.Image")));
this.btnHome.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnHome.Location = new System.Drawing.Point(3, 155);
this.btnHome.Margin = new System.Windows.Forms.Padding(3, 15, 3, 3);
this.btnHome.Name = "btnHome";
this.btnHome.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnHome.Size = new System.Drawing.Size(228, 69);
this.btnHome.TabIndex = 0;
this.btnHome.Text = "Home";
this.btnHome.UseVisualStyleBackColor = true;
this.btnHome.Click += new System.EventHandler(this.btnHome_Click);
//
// btnMasterFiles
//
this.btnMasterFiles.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnMasterFiles.FlatAppearance.BorderSize = 0;
this.btnMasterFiles.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMasterFiles.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnMasterFiles.ForeColor = System.Drawing.Color.White;
this.btnMasterFiles.Image = ((System.Drawing.Image)(resources.GetObject("btnMasterFiles.Image")));
this.btnMasterFiles.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnMasterFiles.Location = new System.Drawing.Point(3, 230);
this.btnMasterFiles.Name = "btnMasterFiles";
this.btnMasterFiles.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnMasterFiles.Size = new System.Drawing.Size(228, 69);
this.btnMasterFiles.TabIndex = 1;
this.btnMasterFiles.Text = "Master Files";
this.btnMasterFiles.UseVisualStyleBackColor = true;
this.btnMasterFiles.Click += new System.EventHandler(this.btnMasterFiles_Click);
//
// btnEmplyeeCenter
//
this.btnEmplyeeCenter.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnEmplyeeCenter.FlatAppearance.BorderSize = 0;
this.btnEmplyeeCenter.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnEmplyeeCenter.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnEmplyeeCenter.ForeColor = System.Drawing.Color.White;
this.btnEmplyeeCenter.Image = ((System.Drawing.Image)(resources.GetObject("btnEmplyeeCenter.Image")));
this.btnEmplyeeCenter.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnEmplyeeCenter.Location = new System.Drawing.Point(3, 305);
this.btnEmplyeeCenter.Name = "btnEmplyeeCenter";
this.btnEmplyeeCenter.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnEmplyeeCenter.Size = new System.Drawing.Size(228, 69);
this.btnEmplyeeCenter.TabIndex = 2;
this.btnEmplyeeCenter.Text = " Emplyee Center";
this.btnEmplyeeCenter.UseVisualStyleBackColor = true;
this.btnEmplyeeCenter.Click += new System.EventHandler(this.btnEmplyeeCenter_Click);
//
// btnPayroll
//
this.btnPayroll.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnPayroll.FlatAppearance.BorderSize = 0;
this.btnPayroll.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnPayroll.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnPayroll.ForeColor = System.Drawing.Color.White;
this.btnPayroll.Image = ((System.Drawing.Image)(resources.GetObject("btnPayroll.Image")));
this.btnPayroll.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnPayroll.Location = new System.Drawing.Point(3, 380);
this.btnPayroll.Name = "btnPayroll";
this.btnPayroll.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnPayroll.Size = new System.Drawing.Size(228, 69);
this.btnPayroll.TabIndex = 3;
this.btnPayroll.Text = "Payroll";
this.btnPayroll.UseVisualStyleBackColor = true;
this.btnPayroll.Click += new System.EventHandler(this.btnPayroll_Click);
//
// panelCollap
//
this.panelCollap.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.panelCollap.Controls.Add(this.btnUserSetup);
this.panelCollap.Controls.Add(this.btnComanySetup);
this.panelCollap.Controls.Add(this.btnSettings);
this.panelCollap.Location = new System.Drawing.Point(3, 755);
this.panelCollap.MaximumSize = new System.Drawing.Size(228, 207);
this.panelCollap.MinimumSize = new System.Drawing.Size(228, 69);
this.panelCollap.Name = "panelCollap";
this.panelCollap.Size = new System.Drawing.Size(228, 69);
this.panelCollap.TabIndex = 3;
//
// btnUserSetup
//
this.btnUserSetup.BackColor = System.Drawing.Color.DimGray;
this.btnUserSetup.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnUserSetup.FlatAppearance.BorderSize = 0;
this.btnUserSetup.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUserSetup.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnUserSetup.ForeColor = System.Drawing.Color.White;
this.btnUserSetup.Image = ((System.Drawing.Image)(resources.GetObject("btnUserSetup.Image")));
this.btnUserSetup.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnUserSetup.Location = new System.Drawing.Point(0, 138);
this.btnUserSetup.Name = "btnUserSetup";
this.btnUserSetup.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnUserSetup.Size = new System.Drawing.Size(228, 69);
this.btnUserSetup.TabIndex = 10;
this.btnUserSetup.Text = "User Setup";
this.btnUserSetup.UseVisualStyleBackColor = false;
//this.btnUserSetup.Click += new System.EventHandler(this.button2_Click);
//////
// btnComanySetup
//
this.btnComanySetup.BackColor = System.Drawing.Color.DimGray;
this.btnComanySetup.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnComanySetup.FlatAppearance.BorderSize = 0;
this.btnComanySetup.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnComanySetup.Font = new System.Drawing.Font("Century Gothic", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnComanySetup.ForeColor = System.Drawing.Color.White;
this.btnComanySetup.Image = ((System.Drawing.Image)(resources.GetObject("btnComanySetup.Image")));
this.btnComanySetup.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnComanySetup.Location = new System.Drawing.Point(0, 69);
this.btnComanySetup.Name = "btnComanySetup";
this.btnComanySetup.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.btnComanySetup.Size = new System.Drawing.Size(228, 69);
this.btnComanySetup.TabIndex = 9;
this.btnComanySetup.Text = "ComanySetup";
this.btnComanySetup.UseVisualStyleBackColor = false;
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.panel1.Controls.Add(this.panel3);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(234, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1281, 82);
this.panel1.TabIndex = 1;
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.panel3.Controls.Add(this.lblDate);
this.panel3.Controls.Add(this.lblTme);
this.panel3.Controls.Add(this.pictureBox3);
this.panel3.Controls.Add(this.pictureBox2);
this.panel3.Controls.Add(this.pictureBox4);
this.panel3.Dock = System.Windows.Forms.DockStyle.Right;
this.panel3.Location = new System.Drawing.Point(720, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(561, 82);
this.panel3.TabIndex = 3;
//
// lblDate
//
this.lblDate.ForeColor = System.Drawing.Color.White;
this.lblDate.Location = new System.Drawing.Point(118, 7);
this.lblDate.Name = "lblDate";
this.lblDate.Size = new System.Drawing.Size(187, 23);
this.lblDate.TabIndex = 7;
this.lblDate.Text = "Date";
//
// lblTme
//
this.lblTme.ForeColor = System.Drawing.Color.White;
this.lblTme.Location = new System.Drawing.Point(311, 7);
this.lblTme.Name = "lblTme";
this.lblTme.Size = new System.Drawing.Size(100, 29);
this.lblTme.TabIndex = 6;
this.lblTme.Text = "Time";
//
// pictureBox3
//
this.pictureBox3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(484, 5);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(27, 26);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox3.TabIndex = 4;
this.pictureBox3.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(437, 5);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(26, 26);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox2.TabIndex = 3;
this.pictureBox2.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(527, 5);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(32, 26);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox4.TabIndex = 5;
this.pictureBox4.TabStop = false;
this.pictureBox4.Click += new System.EventHandler(this.pictureBox4_Click);
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None;
this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(10);
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.hmeToolStripMenuItem,
this.masterToolStripMenuItem,
this.employeeToolStripMenuItem,
this.payrllToolStripMenuItem,
this.attendenceToolStripMenuItem,
this.leaveToolStripMenuItem,
this.performanceToolStripMenuItem,
this.noticeToolStripMenuItem,
this.settingToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(3, 54);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(916, 28);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.fileToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 20, 0);
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24);
this.fileToolStripMenuItem.Text = "File";
//
// hmeToolStripMenuItem
//
this.hmeToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.hmeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 20, 0);
this.hmeToolStripMenuItem.Name = "hmeToolStripMenuItem";
this.hmeToolStripMenuItem.Size = new System.Drawing.Size(53, 24);
this.hmeToolStripMenuItem.Text = "Hme";
//
// masterToolStripMenuItem
//
this.masterToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.masterToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 20, 0);
this.masterToolStripMenuItem.Name = "masterToolStripMenuItem";
this.masterToolStripMenuItem.Size = new System.Drawing.Size(66, 24);
this.masterToolStripMenuItem.Text = "Master";
//
// settingToolStripMenuItem
//
this.settingToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.settingToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 20, 0);
this.settingToolStripMenuItem.Name = "settingToolStripMenuItem";
this.settingToolStripMenuItem.Size = new System.Drawing.Size(68, 24);
this.settingToolStripMenuItem.Text = "Setting";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Montserrat", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.label1.Location = new System.Drawing.Point(19, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(361, 30);
this.label1.TabIndex = 3;
this.label1.Text = "ThirdEye ERP HRM SYSTEM";
//
// sidePanel
//
this.sidePanel.BackColor = System.Drawing.Color.Red;
this.sidePanel.Location = new System.Drawing.Point(-1, 155);
this.sidePanel.Name = "sidePanel";
this.sidePanel.Size = new System.Drawing.Size(10, 69);
this.sidePanel.TabIndex = 2;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer2
//
this.timer2.Interval = 15;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1515, 902);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MainMenuStrip = this.menuStrip1;
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FrmMain";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.flowLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panelCollap.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnHome;
private System.Windows.Forms.Button btnMasterFiles;
private System.Windows.Forms.Button btnEmplyeeCenter;
private System.Windows.Forms.Button btnAttendence;
private System.Windows.Forms.Button btnLeave;
private System.Windows.Forms.Button btnPerformance;
private System.Windows.Forms.Button btnNoticeBoard;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel sidePanel;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblDate;
private System.Windows.Forms.Label lblTme;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem hmeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem masterToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem employeeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem payrllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem attendenceToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem leaveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem performanceToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem noticeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settingToolStripMenuItem;
private System.Windows.Forms.Button btnPayroll;
private System.Windows.Forms.Button btnSettings;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Panel panelCollap;
private System.Windows.Forms.Button btnUserSetup;
private System.Windows.Forms.Button btnComanySetup;
}
i just removed some buttons from design.cs cuz char limitation.
Thanks for helping me.
You have a weird uncommented </param> at the line 6 of your Designer.cs file. You probably left it around after removing those button. Just remove it and it should work fine.

How can I call my windows form elements in my other class in C#

I want to acces a combobox, a chart,... form my form. This is automatically added in my Form1. But now I need the combobox, chart... in another class. How can I reference this to the class DeviceClass? Do I have to make the combobox and others public in my form? Thanks for the help by advance. I tried in DeviceClass to put it like this:
private System.Windows.Forms.ComboBox cboChannels; bit it doesn' work. I think I need to make public it in other way in my from. or do I have to use a return in form?
public class Form1 : System.Windows.Forms.Form
{
DeviceClass d = new DeviceClass();
#region "Windows Form Designer generated code"
public void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.grpDevice = new System.Windows.Forms.GroupBox();
this.btnInitialise = new System.Windows.Forms.Button();
this.cmbdevice = new System.Windows.Forms.ComboBox();
this.lblDevice = new System.Windows.Forms.Label();
this.grpAnalogOut = new System.Windows.Forms.GroupBox();
this.btnApplyOutputSettings = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtClockFreqFile = new System.Windows.Forms.TextBox();
this.lblClockFreqFile = new System.Windows.Forms.Label();
this.lblChListSize = new System.Windows.Forms.Label();
this.txtCglSize = new System.Windows.Forms.Label();
this.lblChListEntry = new System.Windows.Forms.Label();
this.cboEntry = new System.Windows.Forms.ComboBox();
this.lblOutputSignal = new System.Windows.Forms.Label();
this.cboSignalType = new System.Windows.Forms.ComboBox();
this.btnAddModifyOutputChannels = new System.Windows.Forms.Button();
this.cboChannels = new System.Windows.Forms.ComboBox();
this.lblOutputChannel = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblWaveClockFreq = new System.Windows.Forms.Label();
this.txtDaClockFreq = new System.Windows.Forms.TextBox();
this.txtBufferSize = new System.Windows.Forms.TextBox();
this.lblOutputBufferSize = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lblOutputFreq = new System.Windows.Forms.Label();
this.txtOutputFrequency = new System.Windows.Forms.TextBox();
this.grpAnalogInput = new System.Windows.Forms.GroupBox();
this.lblNumOfCh = new System.Windows.Forms.Label();
this.btnApplyInputSettings = new System.Windows.Forms.Button();
this.grpDataAcqMode = new System.Windows.Forms.GroupBox();
this.lblSyncMode = new System.Windows.Forms.Label();
this.cmbSyncMode = new System.Windows.Forms.ComboBox();
this.btnSetNumOfCh = new System.Windows.Forms.Button();
this.cmbNumOfCh = new System.Windows.Forms.ComboBox();
this.grpChSettings = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.OlBufferDataGrid)).BeginInit();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1054, 625);
this.tabControl1.TabIndex = 92;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.grpDevice);
this.tabPage1.Controls.Add(this.grpAnalogOut);
this.tabPage1.Controls.Add(this.grpAnalogInput);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1046, 599);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Setup";
this.tabPage1.UseVisualStyleBackColor = true;
//
// grpDevice
//
this.grpDevice.Controls.Add(this.btnInitialise);
this.grpDevice.Controls.Add(this.cmbdevice);
this.grpDevice.Controls.Add(this.lblDevice);
this.grpDevice.Location = new System.Drawing.Point(5, 5);
this.grpDevice.Name = "grpDevice";
this.grpDevice.Size = new System.Drawing.Size(467, 46);
this.grpDevice.TabIndex = 97;
this.grpDevice.TabStop = false;
this.grpDevice.Text = "Device settings";
//
// btnInitialise
//
this.btnInitialise.Location = new System.Drawing.Point(351, 16);
this.btnInitialise.Name = "btnInitialise";
this.btnInitialise.Size = new System.Drawing.Size(96, 25);
this.btnInitialise.TabIndex = 21;
this.btnInitialise.Text = "Initialize";
this.btnInitialise.Click += new System.EventHandler(this.btnInitialise_Click_1);
//
// cmbdevice
//
this.cmbdevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbdevice.Location = new System.Drawing.Point(197, 18);
this.cmbdevice.Name = "cmbdevice";
this.cmbdevice.Size = new System.Drawing.Size(117, 21);
this.cmbdevice.TabIndex = 63;
//
// lblDevice
//
this.lblDevice.AutoSize = true;
this.lblDevice.Location = new System.Drawing.Point(21, 22);
this.lblDevice.Name = "lblDevice";
this.lblDevice.Size = new System.Drawing.Size(44, 13);
this.lblDevice.TabIndex = 62;
this.lblDevice.Text = "Device:";
this.lblDevice.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// grpAnalogOut
//
this.grpAnalogOut.Controls.Add(this.btnApplyOutputSettings);
this.grpAnalogOut.Controls.Add(this.groupBox1);
this.grpAnalogOut.Controls.Add(this.groupBox2);
this.grpAnalogOut.Controls.Add(this.groupBox3);
this.grpAnalogOut.Location = new System.Drawing.Point(478, 56);
this.grpAnalogOut.Name = "grpAnalogOut";
this.grpAnalogOut.Size = new System.Drawing.Size(467, 298);
this.grpAnalogOut.TabIndex = 96;
this.grpAnalogOut.TabStop = false;
this.grpAnalogOut.Text = "Analog Output";
//
// btnApplyOutputSettings
//
this.btnApplyOutputSettings.Location = new System.Drawing.Point(5, 255);
this.btnApplyOutputSettings.Name = "btnApplyOutputSettings";
this.btnApplyOutputSettings.Size = new System.Drawing.Size(142, 32);
this.btnApplyOutputSettings.TabIndex = 109;
this.btnApplyOutputSettings.Text = "Apply Output Settings";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtClockFreqFile);
this.groupBox1.Controls.Add(this.lblClockFreqFile);
this.groupBox1.Controls.Add(this.lblChListSize);
this.groupBox1.Controls.Add(this.txtCglSize);
this.groupBox1.Controls.Add(this.lblChListEntry);
this.groupBox1.Controls.Add(this.cboEntry);
this.groupBox1.Controls.Add(this.lblOutputSignal);
this.groupBox1.Controls.Add(this.cboSignalType);
this.groupBox1.Controls.Add(this.btnAddModifyOutputChannels);
this.groupBox1.Controls.Add(this.cboChannels);
this.groupBox1.Controls.Add(this.lblOutputChannel);
this.groupBox1.Location = new System.Drawing.Point(7, 114);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(434, 136);
this.groupBox1.TabIndex = 108;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Channel List Setup";
//
// txtClockFreqFile
//
this.txtClockFreqFile.Location = new System.Drawing.Point(342, 55);
this.txtClockFreqFile.Name = "txtClockFreqFile";
this.txtClockFreqFile.Size = new System.Drawing.Size(80, 20);
this.txtClockFreqFile.TabIndex = 110;
//
// lblClockFreqFile
//
this.lblClockFreqFile.Location = new System.Drawing.Point(228, 49);
this.lblClockFreqFile.Name = "lblClockFreqFile";
this.lblClockFreqFile.Size = new System.Drawing.Size(104, 31);
this.lblClockFreqFile.TabIndex = 109;
this.lblClockFreqFile.Text = "Clock frequency output file:";
//
// lblChListSize
//
this.lblChListSize.Location = new System.Drawing.Point(228, 25);
this.lblChListSize.Name = "lblChListSize";
this.lblChListSize.Size = new System.Drawing.Size(104, 16);
this.lblChListSize.TabIndex = 107;
this.lblChListSize.Text = "Channel List Size :";
//
// txtCglSize
//
this.txtCglSize.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtCglSize.Location = new System.Drawing.Point(342, 26);
this.txtCglSize.Name = "txtCglSize";
this.txtCglSize.Size = new System.Drawing.Size(80, 16);
this.txtCglSize.TabIndex = 106;
//
// lblChListEntry
//
this.lblChListEntry.Location = new System.Drawing.Point(9, 24);
this.lblChListEntry.Name = "lblChListEntry";
this.lblChListEntry.Size = new System.Drawing.Size(56, 16);
this.lblChListEntry.TabIndex = 105;
this.lblChListEntry.Text = "Entry :";
this.lblChListEntry.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// cboEntry
//
this.cboEntry.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboEntry.Location = new System.Drawing.Point(115, 24);
this.cboEntry.Name = "cboEntry";
this.cboEntry.Size = new System.Drawing.Size(87, 21);
this.cboEntry.TabIndex = 104;
//
// lblOutputSignal
//
this.lblOutputSignal.Location = new System.Drawing.Point(9, 96);
this.lblOutputSignal.Name = "lblOutputSignal";
this.lblOutputSignal.Size = new System.Drawing.Size(88, 24);
this.lblOutputSignal.TabIndex = 103;
this.lblOutputSignal.Text = "Signal Type:";
this.lblOutputSignal.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// cboSignalType
//
this.cboSignalType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboSignalType.Location = new System.Drawing.Point(115, 96);
this.cboSignalType.Name = "cboSignalType";
this.cboSignalType.Size = new System.Drawing.Size(87, 21);
this.cboSignalType.TabIndex = 102;
//
// btnAddModifyOutputChannels
//
this.btnAddModifyOutputChannels.Location = new System.Drawing.Point(326, 85);
this.btnAddModifyOutputChannels.Name = "btnAddModifyOutputChannels";
this.btnAddModifyOutputChannels.Size = new System.Drawing.Size(96, 32);
this.btnAddModifyOutputChannels.TabIndex = 101;
this.btnAddModifyOutputChannels.Text = "Add/Modify";
//
// cboChannels
//
this.cboChannels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboChannels.Location = new System.Drawing.Point(115, 59);
this.cboChannels.Name = "cboChannels";
this.cboChannels.Size = new System.Drawing.Size(87, 21);
this.cboChannels.TabIndex = 99;
//
// lblOutputChannel
//
this.lblOutputChannel.Location = new System.Drawing.Point(9, 56);
this.lblOutputChannel.Name = "lblOutputChannel";
this.lblOutputChannel.Size = new System.Drawing.Size(88, 16);
this.lblOutputChannel.TabIndex = 100;
this.lblOutputChannel.Text = "Channel :";
this.lblOutputChannel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblWaveClockFreq
//
this.lblWaveClockFreq.Location = new System.Drawing.Point(9, 26);
this.lblWaveClockFreq.Name = "lblWaveClockFreq";
this.lblWaveClockFreq.Size = new System.Drawing.Size(88, 16);
this.lblWaveClockFreq.TabIndex = 7;
this.lblWaveClockFreq.Text = "D/A Clock Freq :";
this.lblWaveClockFreq.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtDaClockFreq
//
this.txtDaClockFreq.Location = new System.Drawing.Point(122, 24);
this.txtDaClockFreq.Name = "txtDaClockFreq";
this.txtDaClockFreq.ReadOnly = true;
this.txtDaClockFreq.Size = new System.Drawing.Size(80, 20);
this.txtDaClockFreq.TabIndex = 12;
//
// txtBufferSize
//
this.txtBufferSize.Location = new System.Drawing.Point(122, 49);
this.txtBufferSize.Name = "txtBufferSize";
this.txtBufferSize.ReadOnly = true;
this.txtBufferSize.Size = new System.Drawing.Size(80, 20);
this.txtBufferSize.TabIndex = 103;
//
// lblOutputBufferSize
//
this.lblOutputBufferSize.Location = new System.Drawing.Point(9, 50);
this.lblOutputBufferSize.Name = "lblOutputBufferSize";
this.lblOutputBufferSize.Size = new System.Drawing.Size(72, 16);
this.lblOutputBufferSize.TabIndex = 102;
this.lblOutputBufferSize.Text = "Buffer Size :";
this.lblOutputBufferSize.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblSyncMode
//
this.lblSyncMode.AutoSize = true;
this.lblSyncMode.Location = new System.Drawing.Point(13, 23);
this.lblSyncMode.Name = "lblSyncMode";
this.lblSyncMode.Size = new System.Drawing.Size(64, 13);
this.lblSyncMode.TabIndex = 2;
this.lblSyncMode.Text = "Sync Mode:";
//
// cmbSyncMode
//
this.cmbSyncMode.Location = new System.Drawing.Point(87, 21);
this.cmbSyncMode.Name = "cmbSyncMode";
this.cmbSyncMode.Size = new System.Drawing.Size(104, 21);
this.cmbSyncMode.TabIndex = 91;
this.cmbSyncMode.Text = "Not supported";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(1190, 618);
this.Controls.Add(this.tabControl1);
this.Name = "Form1";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.grpDevice.ResumeLayout(false);
this.grpDevice.PerformLayout();
this.grpAnalogOut.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.grpAnalogInput.ResumeLayout(false);
this.grpAnalogInput.PerformLayout();
this.grpDataAcqMode.ResumeLayout(false);
this.grpDataAcqMode.PerformLayout();
this.grpChSettings.ResumeLayout(false);
this.grpChSettings.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudChGain)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudChNum)).EndInit();
this.grpClock.ResumeLayout(false);
this.grpClock.PerformLayout();
this.grpBuffering.ResumeLayout(false);
this.grpBuffering.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudNumOfBuffers)).EndInit();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.grpAcqVal.ResumeLayout(false);
this.grpAcqVal.PerformLayout();
this.grpAcqDuration.ResumeLayout(false);
this.grpAcqDuration.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudFiniteDuration)).EndInit();
this.grpPlot.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.OlBufferDataGrid)).EndInit();
this.ResumeLayout(false);
}
private TabControl tabControl1;
private TabPage tabPage1;
private GroupBox grpDevice;
private Button btnInitialise;
private ComboBox cmbdevice;
private Label lblDevice;
private GroupBox grpAnalogOut;
private NumericUpDown nudNumOfBuffers;
private Label lblNumOfBuffers;
private Label lblSamplesPerBuffer;
private TextBox txtSamplesPerBuffer;
private TabPage tabPage2;
private CheckBox chkEnableOutput;
private CheckBox chkEnableInput;
private GroupBox grpAcqVal;
private RadioButton rdoHexadecimal;
private RadioButton rdoDecimal;
private RadioButton rdoWriteToFile;
private Label lblStop;
private Label lblStart;
private GroupBox grpAcqDuration;
private NumericUpDown nudFiniteDuration;
private Label lblDuration;
private Label lblTimePassed;
private RadioButton rdoContinuous;
private RadioButton rdoFinite;
private GroupBox grpPlot;
private ComboBox cmbPlotChNum;
public System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private DateTimePicker dtpMeasurementStop;
private DateTimePicker dtpMeasurementStart;
private Button btnSetMeasurementInterval;
private TextBox txtBuffersCompleted;
private Label lblBuffersDone;
private DataGrid OlBufferDataGrid;
private Button btnStart;
private Button btnStop;
#endregion "Windows Form Designer generated code"
#region "variables"
private DataTable OlBufferDataTable;
private Device device = null;
private DeviceMgr deviceMgr = DeviceMgr.Get();
#endregion "variables"
public Form1()
{
InitializeComponent();
CultureInfo english = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentCulture = english;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (device != null)
{
device.Dispose();
}
}
base.Dispose(disposing);
}
[STAThread]
private static void Main()
{
try
{
Application.Run(new Form1());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error");
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
string[] deviceNames = deviceMgr.GetDeviceNames();
for (int i = 0; i < deviceNames.Length; ++i)
{
cmbdevice.Items.Add(deviceNames[i]);
}
if (cmbdevice.Items.Count > 0)
{
cmbdevice.SelectedIndex = 0;
}
OlBufferDataTable = new DataTable("OlBuffer");
OlBufferDataGrid.DataSource = OlBufferDataTable;
DataRow newRow;
for (int i = 0; i < 10; i++)
{
newRow = OlBufferDataTable.NewRow();
OlBufferDataTable.Rows.Add(newRow);
}
cboSignalType.Items.Add("Sine");
cboSignalType.Items.Add("Ramp");
cboSignalType.Items.Add("Square");
cboSignalType.Items.Add("txt file");
}
private void btnInitialise_Click_1(object sender, EventArgs e)
{
d.weergeven();
}
}
public class DeviceClass
{
public void weergeven()
{
string deviceName = (string)cmbdevice.SelectedItem;
try
{
if (device != null)
{
device.Dispose();
}
device = deviceMgr.GetDevice(deviceName);
ainSS = device.AnalogInputSubsystem(0);
ainSS.DriverRunTimeErrorEvent += new DriverRunTimeErrorEventHandler(HandleDriverRunTimeErrorEvent);
ainSS.DriverRunTimeErrorEvent += new DriverRunTimeErrorEventHandler(HandleDriverRunTimeErrorEvent);
ainSS.BufferDoneEvent += new BufferDoneHandler(HandleBufferDone);
ainSS.QueueDoneEvent += new QueueDoneHandler(HandleQueueDone);
ainSS.QueueStoppedEvent += new QueueStoppedHandler(HandleQueueStopped);
aoutSS = device.AnalogOutputSubsystem(0);
aoutSS.DataFlow = DataFlow.Continuous;
aoutSS.DriverRunTimeErrorEvent += new DriverRunTimeErrorEventHandler(HandleDriverRunTimeErrorEvent);
aoutSS.BufferDoneEvent += new BufferDoneHandler(HandleBufferDone);
aoutSS.QueueDoneEvent += new QueueDoneHandler(HandleQueueDone);
aoutSS.QueueStoppedEvent += new QueueStoppedHandler(HandleQueueStopped);
aoutSS.IOCompleteEvent += new IOCompleteHandler(HandleIOComplete);
signalList = new short[aoutSS.NumberOfChannels];
for (int i = 0; i < aoutSS.NumberOfChannels; ++i)
{
if (aoutSS.SupportedChannels[i].SubsystemType != SubsystemType.AnalogOutput)
continue;
cboChannels.Items.Add(i.ToString());
cboEntry.Items.Add(i.ToString());
}
cboEntry.SelectedIndex = 0;
cboChannels.SelectedIndex = 0;
statusBarPanel.Text = "Output configured without error";
string name;
cmbCouplingType.Items.Clear();
cmbCurrentSource.Items.Clear();
cmbSyncMode.Items.Clear();
if (ainSS.SupportsSynchronization)
{
string[] names = Enum.GetNames(typeof(SynchronizationModes));
for (int i = 0; i < names.Length; i++)
cmbSyncMode.Items.Add(names[i]);
cmbSyncMode.SelectedIndex = 0;
}
else
{
cmbSyncMode.Items.Add("NotSupported");
this.cmbSyncMode.Enabled = false;
cmbSyncMode.SelectedIndex = 0;
}
if (ainSS.SupportsDCCoupling || ainSS.SupportsACCoupling)
{
if (ainSS.SupportsDCCoupling)
{
name = Enum.GetName(typeof(CouplingType), CouplingType.DC);
cmbCouplingType.Items.Add(name);
cmbCouplingType.SelectedIndex = cmbCouplingType.Items.IndexOf(name);
}
if (ainSS.SupportsACCoupling)
{
name = Enum.GetName(typeof(CouplingType), CouplingType.AC);
cmbCouplingType.Items.Add(name);
cmbCouplingType.SelectedIndex = cmbCouplingType.Items.IndexOf(name);
}
this.cmbCouplingType.Enabled = true;
}
else
{
cmbCouplingType.Items.Add("NotSupported");
this.cmbCouplingType.Enabled = false;
cmbCouplingType.SelectedIndex = 0;
}
if (ainSS.SupportsExternalExcitationCurrentSrc || ainSS.SupportsInternalExcitationCurrentSrc)
{
if (ainSS.SupportsExternalExcitationCurrentSrc)
{
name = Enum.GetName(typeof(ExcitationCurrentSource), ExcitationCurrentSource.External);
cmbCurrentSource.Items.Add(name);
cmbCurrentSource.SelectedIndex = cmbCouplingType.Items.IndexOf(name);
}
if (ainSS.SupportsInternalExcitationCurrentSrc)
{
name = Enum.GetName(typeof(ExcitationCurrentSource), ExcitationCurrentSource.Internal);
cmbCurrentSource.Items.Add(name);
cmbCurrentSource.SelectedIndex = cmbCurrentSource.Items.IndexOf(name);
}
name = Enum.GetName(typeof(ExcitationCurrentSource), ExcitationCurrentSource.Disabled);
cmbCurrentSource.Items.Add(name);
cmbCurrentSource.Enabled = true;
cmbCurrentSource.SelectedItem = "Disabled";
}
else
{
cmbCurrentSource.Items.Add("NotSupported");
cmbCurrentSource.Enabled = false;
cmbCurrentSource.SelectedIndex = 0;
}
if (ainSS.SupportsSimultaneousSampleHold)
{
statusBarPanel.Text = "Analog input subsystem supports simultaneous sample and hold data acquiring";
}
}
catch (OlException ex)
{
string err = ex.Message;
statusBarPanel.Text = err;
return;
}
}
}
What I would do:
Pass your form as an object to the class
In your form make a method for altering the UI
(for example:
public void WriteTextBox(string ToWrite)
{
TextBoxName.Text = ToWrite;
}
)
Call this method from your main form

Can't call upon objects, not sure why

So I have a form with 3 buttons in it, "Add Users", "Delete Users", "Change Password". When you click on one of those buttons I don't want a new form to appear, but instead I want the current for to change and show new textboxes & buttons. The problem is that when I code these textboxes and buttons, I can't call upon them as objects in private void BtnAddUser_Click(object sender, Routed EventArgs e).
Can someone please explain what I'm doing wrong?
There error's that I'm getting is that: The name 'txtUsername', 'pbxPassword' and 'cboRangen' do not exist in the current context.
public admin()
{
InitializeComponent();
}
private void btnAddUsers_Click(object sender, RoutedEventArgs e)
{
// Buttons verbergen
btnAddUsers.Visibility = Visibility.Hidden;
btnDeleteUsers.Visibility = Visibility.Hidden;
btnChangePasswords.Visibility = Visibility.Hidden;
// Back button toevoegen
Button btnBack = new Button();
grdAdmin.Children.Add(btnBack);
btnBack.Content = "Back";
btnBack.Visibility = Visibility.Visible;
btnBack.Height = 30;
btnBack.Width = 60;
btnBack.Margin = new Thickness(180, 65, 0, 0);
btnBack.VerticalAlignment = VerticalAlignment.Top;
btnBack.HorizontalAlignment = HorizontalAlignment.Left;
//Textboxes & labels toevoegen
//lblUsername
Label lblUsername = new Label();
grdAdmin.Children.Add(lblUsername);
lblUsername.Content = "USERNAME";
lblUsername.Margin = new Thickness(20, 100, 0, 0);
lblUsername.Padding = new Thickness(0, 5, 5, 5);
lblUsername.Height = 30;
lblUsername.Width = 100;
lblUsername.FontSize = 10;
lblUsername.SetValue(Label.FontWeightProperty, FontWeights.Bold);
lblUsername.Opacity = 60;
lblUsername.VerticalAlignment = VerticalAlignment.Top;
lblUsername.HorizontalAlignment = HorizontalAlignment.Left;
//txtUsername
TextBox txtUsername = new TextBox();
grdAdmin.Children.Add(txtUsername);
txtUsername.Text = "";
txtUsername.Margin = new Thickness(20, 130, 0, 0);
txtUsername.Padding = new Thickness(10, 0, 0, 0);
txtUsername.Height = 30;
txtUsername.Width = 220;
txtUsername.VerticalAlignment = VerticalAlignment.Top;
txtUsername.HorizontalAlignment = HorizontalAlignment.Left;
txtUsername.VerticalContentAlignment = VerticalAlignment.Center;
//lblPassword
Label lblPassword = new Label();
grdAdmin.Children.Add(lblPassword);
lblPassword.Content = "PASSWORD";
lblPassword.Margin = new Thickness(20, 160, 0, 0);
lblPassword.Padding = new Thickness(0, 5, 5, 5);
lblPassword.Height = 30;
lblPassword.Width = 100;
lblPassword.FontSize = 10;
lblPassword.SetValue(Label.FontWeightProperty, FontWeights.Bold);
lblPassword.Opacity = 60;
lblPassword.VerticalAlignment = VerticalAlignment.Top;
lblPassword.HorizontalAlignment = HorizontalAlignment.Left;
//pbxPassword
PasswordBox pbxPassword = new PasswordBox();
grdAdmin.Children.Add(pbxPassword);
pbxPassword.Password = "";
pbxPassword.Margin = new Thickness(20, 190, 0, 0);
pbxPassword.Padding = new Thickness(10, 0, 0, 0);
pbxPassword.Height = 30;
pbxPassword.Width = 220;
pbxPassword.VerticalAlignment = VerticalAlignment.Top;
pbxPassword.HorizontalAlignment = HorizontalAlignment.Left;
pbxPassword.VerticalContentAlignment = VerticalAlignment.Center;
pbxPassword.PasswordChar = '*';
//lblRang
Label lblRang = new Label();
grdAdmin.Children.Add(lblRang);
lblRang.Content = "RANG";
lblRang.Margin = new Thickness(20, 220, 0, 0);
lblRang.Padding = new Thickness(0, 5, 5, 5);
lblRang.Height = 30;
lblRang.Width = 100;
lblRang.FontSize = 10;
lblRang.SetValue(Label.FontWeightProperty, FontWeights.Bold);
lblRang.Opacity = 60;
lblRang.VerticalAlignment = VerticalAlignment.Top;
lblRang.HorizontalAlignment = HorizontalAlignment.Left;
//cboRangen
ComboBox cboRangen = new ComboBox();
grdAdmin.Children.Add(cboRangen);
cboRangen.Margin = new Thickness(20, 250, 0, 0);
cboRangen.Height = 30;
cboRangen.Width = 220;
cboRangen.VerticalAlignment = VerticalAlignment.Top;
cboRangen.HorizontalAlignment = HorizontalAlignment.Left;
cboRangen.Items.Add("Directeur");
cboRangen.Items.Add("Software Manager");
//btnRegister
Button btnAddUser = new Button();
grdAdmin.Children.Add(btnAddUser);
btnAddUser.Content = "Add User";
btnAddUser.Visibility = Visibility.Visible;
btnAddUser.Height = 30;
btnAddUser.Width = 220;
btnAddUser.Margin = new Thickness(20, 300, 0, 0);
btnAddUser.VerticalAlignment = VerticalAlignment.Top;
btnAddUser.HorizontalAlignment = HorizontalAlignment.Left;
btnAddUser.Click += BtnAddUser_Click;
}
private void BtnAddUser_Click(object sender, RoutedEventArgs e)
{
MySqlConnection MySqlCon = new MySqlConnection(connectionStr.ConnectionString);
try
{
if (MySqlCon.State == System.Data.ConnectionState.Closed) MySqlCon.Open();
String query2 = "INSERT INTO egh.accounts (Username,Password,Rang) VALUES(#Username, #Password, #Rang)";
MySqlCommand sqlCmd = new MySqlCommand(query2, MySqlCon);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.Parameters.AddWithValue("#Username", txtUsername.Text);
sqlCmd.Parameters.AddWithValue("#Password", pbxPassword.Text);
sqlCmd.Parameters.AddWithValue("#Rang", cboRangen.SelectedValue);
sqlCmd.ExecuteScalar();
MessageBox.Show("User added!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
MySqlCon.Close();
}
}
}
The variables, that are mentioned, are local to the btnAddUsers_Click() function. They only exist within this function.
To access them, you have several options (including, but not limited to):
Convert the local variables to class members
Find another way to access the component
Add the components at design time and just toggle the visibility.

How do I use the save feature on tabcontols?

I have a form where I can add tabs into a tabcontrol by pressing a button on the form. There are 4 textboxes and then the name of the tab. I have added using system.io;
Where would I even start to create a save for all of the tabs? I have the save button created, I just don't know where to start. I would guess I would need a loop of some kind.
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public string status = "no";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string name = txtName.Text;
//validate information
try { }
catch { }
//create new tab
string title = name;
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
//Add Labels
Label lb = new Label();
lb.Text = "Denomination:";
lb.Location = new System.Drawing.Point(150, 75);
lb.Name = "lbl";
lb.Size = new System.Drawing.Size(100, 20);
myTabPage.Controls.Add(lb);
Label lb2 = new Label();
lb2.Text = "Year:";
lb2.Location = new System.Drawing.Point(150, 120);
lb2.Name = "lbl2";
lb2.Size = new System.Drawing.Size(100, 20);
myTabPage.Controls.Add(lb2);
Label lb3 = new Label();
lb3.Text = "Grade:";
lb3.Location = new System.Drawing.Point(150, 165);
lb3.Name = "lbl3";
lb3.Size = new System.Drawing.Size(100, 20);
myTabPage.Controls.Add(lb3);
Label lb4 = new Label();
lb4.Text = "Mint Mark:";
lb4.Location = new System.Drawing.Point(150, 210);
lb4.Name = "lbl4";
lb4.Size = new System.Drawing.Size(100, 20);
myTabPage.Controls.Add(lb4);
//Add text boxes
TextBox tb = new TextBox();
tb.Location = new System.Drawing.Point(250, 75);
tb.Name = "txt";
tb.Size = new System.Drawing.Size(184, 20);
myTabPage.Controls.Add(tb);
TextBox tb1 = new TextBox();
tb1.Location = new System.Drawing.Point(250, 120);
tb1.Name = "txt1";
tb1.Size = new System.Drawing.Size(184, 20);
myTabPage.Controls.Add(tb1);
TextBox tb2 = new TextBox();
tb2.Location = new System.Drawing.Point(250, 165);
tb2.Name = "txt2";
tb2.Size = new System.Drawing.Size(184, 20);
myTabPage.Controls.Add(tb2);
TextBox tb3 = new TextBox();
tb3.Location = new System.Drawing.Point(250, 210);
tb3.Name = "txt3";
tb3.Size = new System.Drawing.Size(184, 20);
myTabPage.Controls.Add(tb3);
//put data inside of textboxes
tb.Text = txtCoin.Text;
tb1.Text = txtYear.Text;
tb2.Text = txtGrade.Text;
tb3.Text = txtMint.Text;
// Add delete button
Button bn = new Button();
bn.Location = new System.Drawing.Point(560, 350);
bn.Name = "btnDelete";
bn.Text = "Delete";
bn.Size = new System.Drawing.Size(100, 50);
bn.Click += MyClick;
myTabPage.Controls.Add(bn);
}
private void MyClick(object sender, EventArgs e)
{
Form2 myform = new Form2();
myform.ShowDialog();
if (status == "yes")
{ tabControl1.TabPages.Remove(tabControl1.SelectedTab); }
status = "no";
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
int counter;
int ccounter;
string outLine;
string pathFileName = Path.Combine(Application.StartupPath, "coins.dat");
StreamWriter writeIt = new StreamWriter(pathFileName);
for (counter = 0; ((tabControl1.TabCount) -1) != 0 ;)
{
}
writeIt.Close();
}
}
}
Use a foreach loop instead of your for (counter = 0; ((tabControl1.TabCount) -1) != 0 ;) loop:
foreach (TabPage tabPage in tabControl.TabPages)
Your for loop is a infinite loop, do it like that:
for (counter = 0; counter < tabControl1.TabCount; counter++)
{
// Save the tab
}

Categories

Resources