I want to make 2 of columns in DataGrid editable. I tried changing readonly to false, but that didn't help.
So can anyone tell me any other way that I can try or is this something which is not letting it be editable.
Thanks
I went to DataDridView Task and on that particular column I changed ReadOnly 'false'. But this didnt help.
And yes it is a WinForm.
namespace Payroll
{
partial class AttendanceLog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.label11 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnShow = new System.Windows.Forms.Button();
this.cmbMonth = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.cmbYear = new System.Windows.Forms.ComboBox();
this.btnClose = new System.Windows.Forms.Button();
this.dgAttendanceLog = new System.Windows.Forms.DataGridView();
this.btnSave = new System.Windows.Forms.Button();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.slno = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.empId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.empName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.workedDays = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.absentDays = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.weeklyOff = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lateCominBy = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.earlyGoingBy = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgAttendanceLog)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// label11
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label11.ForeColor = System.Drawing.SystemColors.ControlText;
this.label11.Location = new System.Drawing.Point(14, 42);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(49, 13);
this.label11.TabIndex = 106;
this.label11.Text = "Month :";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnShow);
this.groupBox1.Controls.Add(this.cmbMonth);
this.groupBox1.Controls.Add(this.label11);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.cmbYear);
this.groupBox1.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox1.ForeColor = System.Drawing.Color.MidnightBlue;
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(688, 79);
this.groupBox1.TabIndex = 108;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Select";
//
// btnShow
//
this.btnShow.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnShow.ForeColor = System.Drawing.Color.Black;
this.btnShow.Location = new System.Drawing.Point(533, 34);
this.btnShow.Name = "btnShow";
this.btnShow.Size = new System.Drawing.Size(75, 33);
this.btnShow.TabIndex = 108;
this.btnShow.Text = "Show";
this.btnShow.UseVisualStyleBackColor = true;
this.btnShow.Click += new System.EventHandler(this.btnShow_Click);
//
// cmbMonth
//
this.cmbMonth.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmbMonth.FormattingEnabled = true;
this.cmbMonth.Items.AddRange(new object[] {
"Month",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"});
this.cmbMonth.Location = new System.Drawing.Point(83, 34);
this.cmbMonth.Name = "cmbMonth";
this.cmbMonth.Size = new System.Drawing.Size(125, 21);
this.cmbMonth.TabIndex = 104;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.ForeColor = System.Drawing.SystemColors.ControlText;
this.label6.Location = new System.Drawing.Point(283, 42);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(39, 13);
this.label6.TabIndex = 107;
this.label6.Text = "Year :";
//
// cmbYear
//
this.cmbYear.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmbYear.FormattingEnabled = true;
this.cmbYear.Location = new System.Drawing.Point(341, 34);
this.cmbYear.Name = "cmbYear";
this.cmbYear.Size = new System.Drawing.Size(125, 21);
this.cmbYear.TabIndex = 105;
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.ForeColor = System.Drawing.Color.Black;
this.btnClose.Location = new System.Drawing.Point(625, 501);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 33);
this.btnClose.TabIndex = 9;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// dgAttendanceLog
//
this.dgAttendanceLog.AllowUserToAddRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.LightCyan;
this.dgAttendanceLog.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dgAttendanceLog.BackgroundColor = System.Drawing.Color.WhiteSmoke;
this.dgAttendanceLog.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgAttendanceLog.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.slno,
this.empId,
this.empName,
this.workedDays,
this.absentDays,
this.weeklyOff,
this.lateCominBy,
this.earlyGoingBy});
this.dgAttendanceLog.Location = new System.Drawing.Point(12, 107);
this.dgAttendanceLog.Name = "dgAttendanceLog";
this.dgAttendanceLog.RowHeadersVisible = false;
this.dgAttendanceLog.Size = new System.Drawing.Size(688, 388);
this.dgAttendanceLog.TabIndex = 109;
this.dgAttendanceLog.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgAttendanceLog_CellDoubleClick);
//
// btnSave
//
this.btnSave.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSave.ForeColor = System.Drawing.Color.Black;
this.btnSave.Location = new System.Drawing.Point(544, 501);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(75, 33);
this.btnSave.TabIndex = 110;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
this.statusStrip1.Location = new System.Drawing.Point(0, 545);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(711, 22);
this.statusStrip1.TabIndex = 111;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(298, 17);
this.toolStripStatusLabel1.Text = "Note : Please Single click on respective field for manual entry";
//
// slno
//
this.slno.HeaderText = "Sl No.";
this.slno.Name = "slno";
this.slno.Width = 50;
//
// empId
//
this.empId.HeaderText = "Emp. ID";
this.empId.Name = "empId";
this.empId.Width = 75;
//
// empName
//
this.empName.HeaderText = "Emp. Name";
this.empName.Name = "empName";
this.empName.Width = 125;
//
// workedDays
//
this.workedDays.HeaderText = "Worked Days";
this.workedDays.Name = "workedDays";
this.workedDays.ReadOnly = true;
this.workedDays.Width = 75;
//
// absentDays
//
this.absentDays.HeaderText = "Absent Days";
this.absentDays.Name = "absentDays";
this.absentDays.ReadOnly = true;
this.absentDays.Width = 75;
//
// weeklyOff
//
this.weeklyOff.HeaderText = "Weekly Off";
this.weeklyOff.Name = "weeklyOff";
this.weeklyOff.Width = 75;
//
// lateCominBy
//
this.lateCominBy.HeaderText = "Late Going By (in Days)";
this.lateCominBy.Name = "lateCominBy";
//
// earlyGoingBy
//
this.earlyGoingBy.HeaderText = "Early Going By (in Days)";
this.earlyGoingBy.Name = "earlyGoingBy";
//
// AttendanceLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.ClientSize = new System.Drawing.Size(711, 567);
this.ControlBox = false;
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.dgAttendanceLog);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.groupBox1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "AttendanceLog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Attendance Log";
this.Load += new System.EventHandler(this.AttendanceLog_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgAttendanceLog)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label11;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnShow;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.DataGridView dgAttendanceLog;
private System.Windows.Forms.ComboBox cmbMonth;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox cmbYear;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.DataGridViewTextBoxColumn slno;
private System.Windows.Forms.DataGridViewTextBoxColumn empId;
private System.Windows.Forms.DataGridViewTextBoxColumn empName;
private System.Windows.Forms.DataGridViewTextBoxColumn workedDays;
private System.Windows.Forms.DataGridViewTextBoxColumn absentDays;
private System.Windows.Forms.DataGridViewTextBoxColumn weeklyOff;
private System.Windows.Forms.DataGridViewTextBoxColumn lateCominBy;
private System.Windows.Forms.DataGridViewTextBoxColumn earlyGoingBy;
}
}
Ok I found your problem. You most propably are using no DataSource or using a ReadOnlyCollection as Datasource. Then the DataGridView will not allow editing at all.
I have seen the same behaviour as you if I only add Rows to the datagrid. As soon as I use a BindingList as DataSource I am able to edit (clicking once into cell and start to type). You may think about removing your double click handler too as this interferes with the default behaviour.
This works for me:
public class Person
{
public string Name { get; set; }
public string EmpId { get; set; }
}
public MainForm()
{
InitializeComponent();
// bind column to property of person
empName.DataPropertyName = "Name";
empId.DataPropertyName = "EmpId";
// set our bindinglist of persons as datasource
var bindingList = new BindingList<Person>();
bindingList.Add(new Person(){ Name = "John", EmpId = "12345" });
bindingList.Add(new Person(){ Name = "David", EmpId = "12346" });
dgAttendanceLog.DataSource = bindingList;
}
In the WinForms you can set EditMode property of the DataGrid to EditOnEnter.also readonly property of datagrid view should be false. then you can set ReadOnly for each Column.
Related
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.
i tired this namespace Adds
i don't know how to connect my project with neobux server.
{
partial class Register
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(33, 62);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(61, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Username :";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(33, 125);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Password :";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(33, 146);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(120, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Password Confirmation :";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(33, 192);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(38, 13);
this.label4.TabIndex = 3;
this.label4.Text = "Email :";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(33, 245);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(51, 13);
this.label5.TabIndex = 4;
this.label5.Text = "Raferrer :";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(33, 285);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 13);
this.label6.TabIndex = 5;
this.label6.Text = "Birth Year :";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 340);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(93, 13);
this.label7.TabIndex = 6;
this.label7.Text = "Verification Code :";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(33, 390);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(395, 30);
this.checkBox1.TabIndex = 7;
this.checkBox1.Text = "I declare to have read, understood, and accecpted the Terms of Services And\r\nPriv" +
"acy Policy.";
this.checkBox1.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
this.checkBox1.UseVisualStyleBackColor = true;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(33, 444);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(291, 17);
this.checkBox2.TabIndex = 8;
this.checkBox2.Text = "I give my consent to the processing of my personal data.";
this.checkBox2.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(378, 490);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 9;
this.button1.Text = "continue";
this.button1.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(100, 59);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(353, 20);
this.textBox1.TabIndex = 10;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(99, 120);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(354, 20);
this.textBox2.TabIndex = 11;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(160, 145);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(293, 20);
this.textBox3.TabIndex = 12;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(78, 187);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(375, 20);
this.textBox4.TabIndex = 13;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(91, 243);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(362, 20);
this.textBox5.TabIndex = 14;
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(98, 282);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(355, 20);
this.textBox6.TabIndex = 15;
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(133, 338);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(320, 20);
this.textBox7.TabIndex = 16;
//
// Register
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(498, 536);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Register";
this.Text = "Register";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.TextBox textBox7;
}
}
i created this application for register for neobux
i don't know how to connect my project with neobux server.
I have created a Form in c# windows. My form contains a button and a text box and it 's name is textbox2 here and it contains code like this in Form1.Designer.cs :
this.textBox2.Location = new System.Drawing.Point(683, 14);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 22;
Now i have created another class called Programss.cs which will do some task and as the task finished i want to print on my form something like this:
textBox2.txt= "Task finished"; //it should print on the textbox of my Form1.cs
How to access this textBox2(which can only be accessed currently in Form1.Designer.cs) in Programss.cs and my other classes ?
EDIT: After Philip Stuyck's comments:
Here is my Form1.cs code :
namespace S
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
//please see here
public string TextMessage
{
get { return textBox3.Text; }
set { textBox3.Text = value; }
}
private void btnStart_Click(object sender, EventArgs e)
{
btnStart.Enabled = false;
// StartServer();
}
private void btnClose_Click(object sender, EventArgs e)
{
}
}
}
And Program.cs is :
namespace Senter code here
{
class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
/////////////////////////////////////////////////////////////////////////////////////
// OtherImportantClasses.Programs prgms = new OtherImportantClasses.Programs();
Form1 theForm = new Form1();
theForm.TextMessage = "Task finished";
}
}
}
Form1.Designer.cs is:
namespace Shekhar
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
public void InitializeComponent()
{
this.btnClose = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.txtPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.Location = new System.Drawing.Point(313, 11);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 21;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnStart
//
this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnStart.Location = new System.Drawing.Point(227, 12);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(75, 23);
this.btnStart.TabIndex = 20;
this.btnStart.Text = "Start";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// txtPort
//
this.txtPort.Location = new System.Drawing.Point(140, 12);
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(79, 20);
this.txtPort.TabIndex = 19;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(78, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 18);
this.label1.TabIndex = 18;
this.label1.Text = "Port : ";
OtherImportantClasses.Programs prog = new OtherImportantClasses.Programs();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(400, 20);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(276, 18);
this.label2.TabIndex = 18;
this.label2.Text = "Total Number of device connected :";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(683, 14);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 22;
// this.textBox2.Text = "testbox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(81, 60);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(702, 243);
this.textBox3.TabIndex = 23;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(818, 315);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.txtPort);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Shekhar\'s GT06";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
/*
public string TextMessage
{
get
{
return textBox2.Text;
}
set
{
textBox2.Text = value;
}
}
*/
#endregion
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
}
}
Form1.Designer.cs is :
namespace S`enter code here`
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
public void InitializeComponent()
{
this.btnClose = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.txtPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.Location = new System.Drawing.Point(313, 11);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 21;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnStart
//
this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnStart.Location = new System.Drawing.Point(227, 12);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(75, 23);
this.btnStart.TabIndex = 20;
this.btnStart.Text = "Start";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// txtPort
//
this.txtPort.Location = new System.Drawing.Point(140, 12);
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(79, 20);
this.txtPort.TabIndex = 19;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(78, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 18);
this.label1.TabIndex = 18;
this.label1.Text = "Port : ";
OtherImportantClasses.Programs prog = new OtherImportantClasses.Programs();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(400, 20);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(276, 18);
this.label2.TabIndex = 18;
this.label2.Text = "Total Number of device connected :";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(683, 14);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 22;
// this.textBox2.Text = "testbox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(81, 60);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(702, 243);
this.textBox3.TabIndex = 23;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(818, 315);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.txtPort);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Shekhar\'s GT06";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
/*
public string TextMessage
{
get
{
return textBox2.Text;
}
set
{
textBox2.Text = value;
}
}
*/
#endregion
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
}
}
It dont give any error but it do not print anything in textBox3 .
NOTE: Please note that first i run the winform code i click a button and when i click the button some proccess will run which will further print the text in the textbox. (I feel like my textmessage is not intialized by my message passed to it).
Make sure that textBox2 is public.(can be done in the designer)
Keep a reference to Form1 when you create it and access textBox2 via that reference.
Form1 theForm = new Form1();
... //do stuff
theForm.textBox2.Text = "Task finished";
This is not the most elegant approach to this, but it should work.
An alternative is like this :
public partial class Form1{
public string TextMessage{
get{
return textBox2.Text;
}
set{
textBox2.Text = value;
}
}
}
and in program.cs
Form1 theForm = new Form1();
... //do stuff
theForm.TextMessage = "Task finished";
your code will not work because
Form1 theForm = new Form1();
theForm.TextMessage = "Task finished";
is never executed.
Application.Run(new Form1());
returns only when the form is closed and then the application will end.
Following will work:
Form1 theForm = new Form1();
theForm.TextMessage = "Task finished";
Application.Run(theForm);
But I have the feeling you don't quite understand the framework.
Application.run, will make your application enter into a message loop which makes the application receive window messages.
One way you could do this is to have a method accessible in your Form1 that sets the textBox name to whatever you want. For instance:
public static void SetText (string message)
{
TextBox2.Text = message;
}
You would then call this from your Program.cs class:
Form1.SetText("Whatever text you want the text on the Form1 - TextBox2 to say");
This is the poor man's way of changing the text. There is a more detailed explanation on this other post if you need more details.
As I understood you want to print end result on textBox2.txt textbox, right? So you want to execute some methods on Programss.cs and once execution is finished you want to show "Task finished" on textBox2.txt.
If I am not wrong, what you have to do is return a value from a method from Programss.cs class. You have to call this method from Form1.Designer.cs class. Based on return value you can do whatever you want.
Hope this will be helpful.
You are creating two separate forms, setting text on the second, and expecting it to appear on the first.
Do this:
Form1 theForm = new Form1();
theForm.TextMessage = "Task finished";
Application.Run(theForm);
I decided to change a listBox1 item in my form1 designer to public static instead of private to access it on another form. And once I had done that It had errored and not allowed me to changed things on the form itself and just tells me this error at the top
The variable 'listBox1' is either undeclared or was never assigned.
The error is shown on the following line
this.panel1.Controls.Add(listBox1);
My Designer for my form below:
namespace Mercury.Forms
{
partial class Inside
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
Inside.listBox1 = new System.Windows.Forms.ListBox();
this.label3 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.White;
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Image = global::Mercury.Properties.Resources.pooltablegodass_500x750;
this.pictureBox1.Location = new System.Drawing.Point(12, 11);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(54, 48);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.label1.Location = new System.Drawing.Point(74, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(82, 20);
this.label1.TabIndex = 1;
this.label1.Text = "Ash Smith";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.label2.Location = new System.Drawing.Point(76, 37);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 13);
this.label2.TabIndex = 2;
this.label2.Text = "ashleytechie";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(listBox1);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 348);
this.panel1.TabIndex = 3;
//
// listBox1
//
listBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
listBox1.ForeColor = System.Drawing.SystemColors.Window;
listBox1.FormattingEnabled = true;
listBox1.ItemHeight = 15;
listBox1.Items.AddRange(new object[] {
"Jake Simpson",
"Adam Jones",
"Jane Peters",
"Ashley Smith",
"Sam Smith",
"Joe Phelan",
"Peter Black",
"Tracy Bratford",
"Jamie Harrison",
"Peter Slims"});
listBox1.Location = new System.Drawing.Point(16, 107);
listBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
listBox1.Name = "listBox1";
listBox1.Size = new System.Drawing.Size(144, 180);
listBox1.TabIndex = 3;
listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.ForeColor = System.Drawing.SystemColors.Window;
this.label3.Location = new System.Drawing.Point(12, 79);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(105, 24);
this.label3.TabIndex = 4;
this.label3.Text = "Contact List";
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(205, 7);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(518, 335);
this.panel2.TabIndex = 4;
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.button1.Location = new System.Drawing.Point(16, 304);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(170, 31);
this.button1.TabIndex = 5;
this.button1.Text = "Edit Profile";
this.button1.UseVisualStyleBackColor = true;
//
// Inside
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.ClientSize = new System.Drawing.Size(730, 347);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "Inside";
this.Text = "Inside";
this.Load += new System.EventHandler(this.Inside_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel panel1;
public static System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
}
}
Change this back to what it was previously: (public to private, remove static)
public static System.Windows.Forms.ListBox listBox1;
Add this in the code-behind in your Form: (you don't need a setter since you won't be creating a new ListBox from the other Forms... I hope)
public ListBox MyListBox
{
get { return listBox1; }
}
Now in other Forms (assuming they're being created by some process in your first Form), you'll pass a reference to the current instance of your Form with the ListBox on it, so you can actually access the public property you just created:
public class SecondForm : Form
{
public SecondForm(FirstForm firstForm)
{
// do something with firstForm.MyListBox
}
}
Lastly, I'd say be careful how much you do this. Forms being able to access each other's controls seems messy to me. If you added more details about exactly what you're trying to accomplish with this, we might be able to provide a better alternative.
Your issue is that you changed the code in the designer file so that listBox1 is now static. You can't do this because the designer must be able to instantiate an instance of ListBox.
What it sounds like you are trying to do is you are trying to modify the listbox from another form. The proper way you should do this is through properties. In your code (not the designer code, but the code behind code), have something like this:
public ListBox MyListBox
{
get
{
return listBox1;
}
}
You shouldn't change anything in the .Designer.cs file. If you want to change access modifiers you should do so through the Properties window.
That being said, your public change was fine, you just can't make it static. For the designer to function all the controls in the form must be independent to each instantiation.
// what the code will look like when you change it from the Properties window
public System.Windows.Forms.ListBox listBox1;
If you were to make the ListBox static, you would access it like
ListBox listbox = Inside.listBox1;
which doesn't make much sense if you have more than one Inside form floating around. If you make it non-static you can still access it from wherever you want as long as you have an instance of the Inside class.
Inside inside = new Inside();
ListBox listbox = inside.listBox1;
I have a .mdb file with a Customers table and an Agents table. The only thing that the Agents table does as yet is populate the Agent dropdown for each customer...
I have a DataGridView linked to the customerBindingSource. The customerBindingSource has DataMember set to Customer and DataSource set to bindingSource1. This has the DataSource set to customerAppDS21. If I select customerAppDS21 and click Edit in DataSet Designer I can quite clearly see that there is a Customer table and Agent table. These were dragged directly from the Data.mdf > Tables folder. I have been through the Configure wizard and checked that the Update, Insert and Delete commands are generated correctly.
I am setting the unique ID (GUID) when the user leaves a row or adds a row (I dont think both are needed, but I very much doubt this is the cause of the problem). The user can update or add as many rows as possible. When the user clicks the Save button it calls customerTableAdapter.Update(customerAppDS21.Customer);. All the events are definitely wired up correctly.
The problem is basically that the DataSet appears to get updated but the database itself is not updated. I can close the program and reload it straight away and the data is there. However if I make any changes to the code and then recompile and load the program all the data is gone. This is what makes me think the DataSet is being updated but not the database.
Does anyone have any idea how to solve the problem? I have tried adding the .acceptChanges(); line both before and after the .Update(bla); line, with no success. I have also tried calling customerBindingSource.EndEdit(); and bindingSource1.EndEdit(); before the .Update(bla); line.
Any help with this would be greatly appreciated. I have had this problem for 2 days now and tried alsorts of tutorials to get a hint on where I am going wrong.
Regards,
Richard
Update: Code below...
void button1_Click(object sender, EventArgs e)
{
Validate();
customerBindingSource.EndEdit();
customerTableAdapter.Update(customerAppDS21.Customer);
}
void grdCustomers_RowLeave(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow gvr = grdCustomers.Rows[e.RowIndex];
if (gvr.Cells[0].Value == null)
{
String g = Guid.NewGuid().ToString();
gvr.Cells[0].Value = g;
}
else
{
String currID = gvr.Cells[0].Value.ToString();
if (currID.Equals(""))
{
String g = Guid.NewGuid().ToString();
gvr.Cells[0].Value = g;
}
}
}
void grdCustomers_UserAddedRow(object sender, DataGridViewRowEventArgs e)
{
DataGridViewRow gvr = grdCustomers.Rows[grdCustomers.SelectedCells[0].RowIndex];
if (gvr.Cells[0].Value == null)
{
String g = Guid.NewGuid().ToString();
gvr.Cells[0].Value = g;
}
else
{
String currID = gvr.Cells[0].Value.ToString();
if (currID.Equals(""))
{
String g = Guid.NewGuid().ToString();
gvr.Cells[0].Value = g;
}
}
}
Designer code (sorry its so long - I dont want to risk missing out anything vital):
namespace CustomerApp
{
partial class CustomerAppForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.button1 = new System.Windows.Forms.Button();
this.grdCustomers = new System.Windows.Forms.DataGridView();
this.agentBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
this.customerAppDS21 = new CustomerApp.CustomerAppDS2();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.customerTableAdapter = new CustomerApp.CustomerAppDS2TableAdapters.CustomerTableAdapter();
this.agentTableAdapter = new CustomerApp.CustomerAppDS2TableAdapters.AgentTableAdapter();
this.customerBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companynameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contactforenameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contactsurnameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companyaddress1DataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companyaddress2DataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companytownDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companycountyDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companypostcodeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contacttelephoneDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contactfaxDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contactemailDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.agentIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.contactfullnameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.grdCustomers)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.agentBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.customerAppDS21)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.customerBindingSource)).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(1000, 640);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.button1);
this.tabPage1.Controls.Add(this.grdCustomers);
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(992, 614);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Customers";
this.tabPage1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(882, 462);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Save";
this.button1.UseVisualStyleBackColor = true;
//
// grdCustomers
//
this.grdCustomers.AllowUserToOrderColumns = true;
this.grdCustomers.AutoGenerateColumns = false;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.grdCustomers.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.grdCustomers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.grdCustomers.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.idDataGridViewTextBoxColumn,
this.companynameDataGridViewTextBoxColumn,
this.contactforenameDataGridViewTextBoxColumn,
this.contactsurnameDataGridViewTextBoxColumn,
this.companyaddress1DataGridViewTextBoxColumn,
this.companyaddress2DataGridViewTextBoxColumn,
this.companytownDataGridViewTextBoxColumn,
this.companycountyDataGridViewTextBoxColumn,
this.companypostcodeDataGridViewTextBoxColumn,
this.contacttelephoneDataGridViewTextBoxColumn,
this.contactfaxDataGridViewTextBoxColumn,
this.contactemailDataGridViewTextBoxColumn,
this.agentIDDataGridViewTextBoxColumn,
this.contactfullnameDataGridViewTextBoxColumn});
this.grdCustomers.DataSource = this.customerBindingSource;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.grdCustomers.DefaultCellStyle = dataGridViewCellStyle2;
this.grdCustomers.Location = new System.Drawing.Point(3, 3);
this.grdCustomers.Name = "grdCustomers";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.grdCustomers.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.grdCustomers.RowTemplate.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.grdCustomers.RowTemplate.DefaultCellStyle.Padding = new System.Windows.Forms.Padding(2);
this.grdCustomers.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.grdCustomers.Size = new System.Drawing.Size(983, 605);
this.grdCustomers.TabIndex = 0;
//
// agentBindingSource
//
this.agentBindingSource.DataMember = "Agent";
this.agentBindingSource.DataSource = this.bindingSource1;
//
// bindingSource1
//
this.bindingSource1.AllowNew = true;
this.bindingSource1.DataSource = this.customerAppDS21;
this.bindingSource1.Position = 0;
//
// customerAppDS21
//
this.customerAppDS21.DataSetName = "CustomerAppDS2";
this.customerAppDS21.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(992, 614);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Agents";
this.tabPage2.UseVisualStyleBackColor = true;
//
// customerTableAdapter
//
this.customerTableAdapter.ClearBeforeFill = true;
//
// agentTableAdapter
//
this.agentTableAdapter.ClearBeforeFill = true;
//
// customerBindingSource
//
this.customerBindingSource.DataMember = "Customer";
this.customerBindingSource.DataSource = this.bindingSource1;
//
// idDataGridViewTextBoxColumn
//
this.idDataGridViewTextBoxColumn.DataPropertyName = "id";
this.idDataGridViewTextBoxColumn.HeaderText = "id";
this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn";
this.idDataGridViewTextBoxColumn.ReadOnly = true;
//
// companynameDataGridViewTextBoxColumn
//
this.companynameDataGridViewTextBoxColumn.DataPropertyName = "company_name";
this.companynameDataGridViewTextBoxColumn.HeaderText = "Company Name";
this.companynameDataGridViewTextBoxColumn.Name = "companynameDataGridViewTextBoxColumn";
this.companynameDataGridViewTextBoxColumn.ToolTipText = "The name of the company";
//
// contactforenameDataGridViewTextBoxColumn
//
this.contactforenameDataGridViewTextBoxColumn.DataPropertyName = "contact_forename";
this.contactforenameDataGridViewTextBoxColumn.HeaderText = "Contact Forename";
this.contactforenameDataGridViewTextBoxColumn.Name = "contactforenameDataGridViewTextBoxColumn";
//
// contactsurnameDataGridViewTextBoxColumn
//
this.contactsurnameDataGridViewTextBoxColumn.DataPropertyName = "contact_surname";
this.contactsurnameDataGridViewTextBoxColumn.HeaderText = "Contact Surname";
this.contactsurnameDataGridViewTextBoxColumn.Name = "contactsurnameDataGridViewTextBoxColumn";
//
// companyaddress1DataGridViewTextBoxColumn
//
this.companyaddress1DataGridViewTextBoxColumn.DataPropertyName = "company_address1";
this.companyaddress1DataGridViewTextBoxColumn.HeaderText = "Address 1";
this.companyaddress1DataGridViewTextBoxColumn.Name = "companyaddress1DataGridViewTextBoxColumn";
//
// companyaddress2DataGridViewTextBoxColumn
//
this.companyaddress2DataGridViewTextBoxColumn.DataPropertyName = "company_address2";
this.companyaddress2DataGridViewTextBoxColumn.HeaderText = "Address 2";
this.companyaddress2DataGridViewTextBoxColumn.Name = "companyaddress2DataGridViewTextBoxColumn";
//
// companytownDataGridViewTextBoxColumn
//
this.companytownDataGridViewTextBoxColumn.DataPropertyName = "company_town";
this.companytownDataGridViewTextBoxColumn.HeaderText = "Town";
this.companytownDataGridViewTextBoxColumn.Name = "companytownDataGridViewTextBoxColumn";
//
// companycountyDataGridViewTextBoxColumn
//
this.companycountyDataGridViewTextBoxColumn.DataPropertyName = "company_county";
this.companycountyDataGridViewTextBoxColumn.HeaderText = "County";
this.companycountyDataGridViewTextBoxColumn.Name = "companycountyDataGridViewTextBoxColumn";
//
// companypostcodeDataGridViewTextBoxColumn
//
this.companypostcodeDataGridViewTextBoxColumn.DataPropertyName = "company_postcode";
this.companypostcodeDataGridViewTextBoxColumn.HeaderText = "Postcode";
this.companypostcodeDataGridViewTextBoxColumn.Name = "companypostcodeDataGridViewTextBoxColumn";
//
// contacttelephoneDataGridViewTextBoxColumn
//
this.contacttelephoneDataGridViewTextBoxColumn.DataPropertyName = "contact_telephone";
this.contacttelephoneDataGridViewTextBoxColumn.HeaderText = "Telephone";
this.contacttelephoneDataGridViewTextBoxColumn.Name = "contacttelephoneDataGridViewTextBoxColumn";
//
// contactfaxDataGridViewTextBoxColumn
//
this.contactfaxDataGridViewTextBoxColumn.DataPropertyName = "contact_fax";
this.contactfaxDataGridViewTextBoxColumn.HeaderText = "Fax";
this.contactfaxDataGridViewTextBoxColumn.Name = "contactfaxDataGridViewTextBoxColumn";
//
// contactemailDataGridViewTextBoxColumn
//
this.contactemailDataGridViewTextBoxColumn.DataPropertyName = "contact_email";
this.contactemailDataGridViewTextBoxColumn.HeaderText = "Email";
this.contactemailDataGridViewTextBoxColumn.Name = "contactemailDataGridViewTextBoxColumn";
//
// agentIDDataGridViewTextBoxColumn
//
this.agentIDDataGridViewTextBoxColumn.DataPropertyName = "agentID";
this.agentIDDataGridViewTextBoxColumn.DataSource = this.agentBindingSource;
this.agentIDDataGridViewTextBoxColumn.DisplayMember = "contact_fullname";
this.agentIDDataGridViewTextBoxColumn.HeaderText = "agentID";
this.agentIDDataGridViewTextBoxColumn.Name = "agentIDDataGridViewTextBoxColumn";
this.agentIDDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.agentIDDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.agentIDDataGridViewTextBoxColumn.ValueMember = "id";
//
// contactfullnameDataGridViewTextBoxColumn
//
this.contactfullnameDataGridViewTextBoxColumn.DataPropertyName = "contact_fullname";
this.contactfullnameDataGridViewTextBoxColumn.HeaderText = "contact_fullname";
this.contactfullnameDataGridViewTextBoxColumn.Name = "contactfullnameDataGridViewTextBoxColumn";
this.contactfullnameDataGridViewTextBoxColumn.ReadOnly = true;
this.contactfullnameDataGridViewTextBoxColumn.Visible = false;
//
// CustomerAppForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1184, 662);
this.Controls.Add(this.tabControl1);
this.Location = new System.Drawing.Point(100, 100);
this.Name = "CustomerAppForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Heritage Art Papers Ltd - Customer Application";
this.Load += new System.EventHandler(this.CustomerAppForm_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.grdCustomers)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.agentBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.customerAppDS21)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.customerBindingSource)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.BindingSource bindingSource1;
private CustomerAppDS2 customerAppDS21;
private System.Windows.Forms.BindingSource agentBindingSource;
private CustomerAppDS2TableAdapters.CustomerTableAdapter customerTableAdapter;
private CustomerAppDS2TableAdapters.AgentTableAdapter agentTableAdapter;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.BindingSource customerBindingSource;
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companynameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contactforenameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contactsurnameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companyaddress1DataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companyaddress2DataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companytownDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companycountyDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn companypostcodeDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contacttelephoneDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contactfaxDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contactemailDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewComboBoxColumn agentIDDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contactfullnameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridView grdCustomers;
}
}
I guess this might be your problem. Read these two articles very carefully. The first one contains a thread where in the second link (I gave below) is suggested.
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic58794.aspx
and
http://msdn.microsoft.com/en-us/library/ms246989.aspx
In the first link, read the answer of: Kerry Moorman.
I guess these links might help:
http://msdn.microsoft.com/en-us/library/xzb1zw3x%28VS.80%29.aspx
and
http://www.c-sharpcorner.com/UploadFile/Ashish1/dataset02052006180740PM/dataset.aspx