I am adding value to a textbox on webpage.
Here is the Inspect Element code:
<input type="text" name="DERIVED_LAM_GRADE_1$0" id="DERIVED_LAM_GRADE_1$0"
tabindex="90" value="0.00" class="PSEDITBOX" style="width:44px;
text-align:right; " maxlength="6" onchange="addchg_win0(this);oChange_win0=this;">
and here is my C# code:
Which is giving me Exception "Object reference not set to an instance of an object."
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("DERIVED_LAM_GRADE_1$0").SetAttribute("value", username);
}
}
}
i Dont know whats wrong. i am giving a perfect id and still its throwing exception.
Designer CODE:
namespace WindowsFormsApplication2
{
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>
private void InitializeComponent()
{
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(527, 309);
this.webBrowser1.TabIndex = 0;
this.webBrowser1.Url = new System.Uri("http://cms.nust.edu.pk/psp/ps/?cmd=login", System.UriKind.Absolute);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.button1);
this.splitContainer1.Panel1.Controls.Add(this.label2);
this.splitContainer1.Panel1.Controls.Add(this.label1);
this.splitContainer1.Panel1.Controls.Add(this.textBox2);
this.splitContainer1.Panel1.Controls.Add(this.textBox1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.webBrowser1);
this.splitContainer1.Size = new System.Drawing.Size(527, 398);
this.splitContainer1.SplitterDistance = 85;
this.splitContainer1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(330, 31);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Insert";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(149, 61);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Password";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(149, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Username";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(208, 58);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(208, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(527, 398);
this.Controls.Add(this.splitContainer1);
this.Name = "Form1";
this.Text = "Form1";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
}
}
Related
I am new to the windows form and i am doing some exercise. I have two form Main form and Summary form. On main form i type data and on the summary form will display data that i enter. The problem is i want to display current and previous data. Is there anyway to do it. I am new so can you show me the basic way not using data grid view? Thank you very much.
This is my MainForm.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Asignment8
{
public partial class MainForm : Form
{
Summary summary;
public MainForm()
{
InitializeComponent();
}
private void SubmitButton_Click(object sender, EventArgs e)
{
string data = FlightIdTextBox.Text + ";" + OriginTextBox.Text + ";" + DestinationTextBox.Text + ";" + DateBox.Text + ";" + TimeTextBox.Text;
if (summary == null || summary.IsDisposed)
{
summary = new Summary();
}
summary.AddData(data);
summary.Show();
}
}
}
This is my MainForm.Designer.cs:
namespace Asignment8
{
partial class MainForm
{
/// <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.flightId = new System.Windows.Forms.Label();
this.origin = new System.Windows.Forms.Label();
this.destination = new System.Windows.Forms.Label();
this.date = new System.Windows.Forms.Label();
this.time = new System.Windows.Forms.Label();
this.submitButton = new System.Windows.Forms.Button();
this.DateBox = new System.Windows.Forms.DateTimePicker();
this.FlightIdTextBox = new System.Windows.Forms.TextBox();
this.OriginTextBox = new System.Windows.Forms.TextBox();
this.DestinationTextBox = new System.Windows.Forms.TextBox();
this.TimeTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// flightId
//
this.flightId.AutoSize = true;
this.flightId.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.flightId.Location = new System.Drawing.Point(122, 78);
this.flightId.Name = "flightId";
this.flightId.Size = new System.Drawing.Size(86, 25);
this.flightId.TabIndex = 0;
this.flightId.Text = "Flight Id:";
//
// origin
//
this.origin.AutoSize = true;
this.origin.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.origin.Location = new System.Drawing.Point(122, 119);
this.origin.Name = "origin";
this.origin.Size = new System.Drawing.Size(70, 25);
this.origin.TabIndex = 1;
this.origin.Text = "Origin:";
//
// destination
//
this.destination.AutoSize = true;
this.destination.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.destination.Location = new System.Drawing.Point(122, 158);
this.destination.Name = "destination";
this.destination.Size = new System.Drawing.Size(115, 25);
this.destination.TabIndex = 2;
this.destination.Text = "Destination:";
//
// date
//
this.date.AutoSize = true;
this.date.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.date.Location = new System.Drawing.Point(122, 198);
this.date.Name = "date";
this.date.Size = new System.Drawing.Size(59, 25);
this.date.TabIndex = 3;
this.date.Text = "Date:";
//
// time
//
this.time.AutoSize = true;
this.time.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.time.Location = new System.Drawing.Point(122, 235);
this.time.Name = "time";
this.time.Size = new System.Drawing.Size(62, 25);
this.time.TabIndex = 4;
this.time.Text = "Time:";
//
// submitButton
//
this.submitButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.submitButton.Location = new System.Drawing.Point(357, 300);
this.submitButton.Name = "submitButton";
this.submitButton.Size = new System.Drawing.Size(79, 30);
this.submitButton.TabIndex = 5;
this.submitButton.Text = "Submit";
this.submitButton.UseVisualStyleBackColor = true;
this.submitButton.Click += new System.EventHandler(this.SubmitButton_Click);
//
// DateBox
//
this.DateBox.CalendarFont = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.DateBox.Location = new System.Drawing.Point(304, 203);
this.DateBox.Name = "DateBox";
this.DateBox.Size = new System.Drawing.Size(205, 20);
this.DateBox.TabIndex = 6;
//
// FlightIdTextBox
//
this.FlightIdTextBox.Location = new System.Drawing.Point(304, 83);
this.FlightIdTextBox.Name = "FlightIdTextBox";
this.FlightIdTextBox.Size = new System.Drawing.Size(205, 20);
this.FlightIdTextBox.TabIndex = 7;
//
// OriginTextBox
//
this.OriginTextBox.Location = new System.Drawing.Point(304, 124);
this.OriginTextBox.Name = "OriginTextBox";
this.OriginTextBox.Size = new System.Drawing.Size(205, 20);
this.OriginTextBox.TabIndex = 8;
//
// DestinationTextBox
//
this.DestinationTextBox.Location = new System.Drawing.Point(304, 163);
this.DestinationTextBox.Name = "DestinationTextBox";
this.DestinationTextBox.Size = new System.Drawing.Size(205, 20);
this.DestinationTextBox.TabIndex = 9;
//
// TimeTextBox
//
this.TimeTextBox.Location = new System.Drawing.Point(304, 240);
this.TimeTextBox.Name = "TimeTextBox";
this.TimeTextBox.Size = new System.Drawing.Size(205, 20);
this.TimeTextBox.TabIndex = 10;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.TimeTextBox);
this.Controls.Add(this.DestinationTextBox);
this.Controls.Add(this.OriginTextBox);
this.Controls.Add(this.FlightIdTextBox);
this.Controls.Add(this.DateBox);
this.Controls.Add(this.submitButton);
this.Controls.Add(this.time);
this.Controls.Add(this.date);
this.Controls.Add(this.destination);
this.Controls.Add(this.origin);
this.Controls.Add(this.flightId);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label flightId;
private System.Windows.Forms.Label origin;
private System.Windows.Forms.Label destination;
private System.Windows.Forms.Label date;
private System.Windows.Forms.Label time;
private System.Windows.Forms.Button submitButton;
private System.Windows.Forms.DateTimePicker DateBox;
private System.Windows.Forms.TextBox FlightIdTextBox;
private System.Windows.Forms.TextBox OriginTextBox;
private System.Windows.Forms.TextBox DestinationTextBox;
private System.Windows.Forms.TextBox TimeTextBox;
}
}
This is my Summary.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Asignment8
{
public partial class Summary : Form
{
StringBuilder allData = new StringBuilder();
public Summary()
{
InitializeComponent();
}
public void AddData(string data)
{
allData.Append(data);
label1.Text = allData.ToString();
}
}
}
This is my Summary.Designer.cs:
namespace Asignment8
{
partial class Summary
{
/// <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.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(237, 135);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 16);
this.label1.TabIndex = 0;
//
// Summary
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1067, 554);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Summary";
this.Text = "Summary";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}
I am basing my answer of Serhii comment about using list boxes as the question stated they did not want to use a DGV.
Main Form :
Summary summary;
List<String> data = new List<String>();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
data.Add(textBox1.Text);
if (summary == null || summary.IsDisposed)
{
summary = new Summary();
}
summary.AddData(data);
summary.Show();
}
Summary Form :
public Summary()
{
InitializeComponent();
}
public void AddData(List<String> lstData)
{
listBox1.Items.Clear();
foreach(var item in lstData)
{
listBox1.Items.Add(item.ToString());
}
}
Final result :
When I try to execute my windows form application, all I see is a completely white blank form. When I look in my form1.cs[Design] everything looks normal, but not when I run it? I can't see the labels, or the buttons or anything. I've never had this issue before and my InitializeComponent I think is where it should be? Here is my Form1.Designer.Cs, or maybe there's an issue in my form1.cs?
partial class Identity
{
/// <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.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(278, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(116, 87);
this.label1.TabIndex = 0;
this.label1.Text = "VÄLKOMMEN!";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(67, 87);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(222, 23);
this.label2.TabIndex = 1;
this.label2.Text = "Skriv in ditt namn och personnummer nedan.:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(67, 181);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(51, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Förnamn:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(63, 217);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(58, 13);
this.label4.TabIndex = 3;
this.label4.Text = "Efternamn:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(30, 269);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(161, 13);
this.label5.TabIndex = 4;
this.label5.Text = "Personummer:(ååååmmdd - xxxx)";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(127, 174);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 5;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(127, 210);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 6;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(197, 266);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(164, 20);
this.textBox3.TabIndex = 7;
//
// button1
//
this.button1.Location = new System.Drawing.Point(307, 329);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(87, 51);
this.button1.TabIndex = 8;
this.button1.Text = "Kör!";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(337, 395);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(35, 13);
this.label6.TabIndex = 9;
this.label6.Text = "label6";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(33, 423);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(492, 296);
this.richTextBox1.TabIndex = 10;
this.richTextBox1.Text = "\"\"";
//
// button2
//
this.button2.Location = new System.Drawing.Point(662, 650);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(116, 69);
this.button2.TabIndex = 11;
this.button2.Text = "Avsluta:";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Identity
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1207, 755);
this.Controls.Add(this.button2);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.label6);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
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 = "Identity";
this.Text = "Form1";
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.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button button2;
private EventHandler label1_Click;
}
}
Here I am calling the IntializeComponent in my Form1.cs, I haven't moved it since I started this new program at all.
public partial class Identity : Form
{
public Identity()
{
InitializeComponent();
}
public struct Person
{
public double idok;
public string fname;
public string lname;
public string id;
public string sex;
public string year;
public string fyear;
}
Per the comment trail, you made a new solution, copied some select lines over from the problematic form's designer code, commented out some event handlers that were missing in the designer code, and then were able to load the designer and add the missing event handlers and their body code. The resulting form worked OK
I want to delete record from database with checkbox in telerik radgridview
...
Please Help Me!
Thanks
See the code below. That should do what you want!!
namespace WindowsFormsApplication6
{
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>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.button2 = new System.Windows.Forms.Button();
this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 13);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(113, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Import Data";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1});
this.dataGridView1.Location = new System.Drawing.Point(13, 43);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(692, 209);
this.dataGridView1.TabIndex = 1;
//this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// button2
//
this.button2.Location = new System.Drawing.Point(144, 13);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(113, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Export Data";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Column1
//
this.Column1.HeaderText = "Column1";
this.Column1.Name = "Column1";
//
// button3
//
this.button3.Location = new System.Drawing.Point(331, 13);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(183, 23);
this.button3.TabIndex = 3;
this.button3.Text = "Delete If CheckBox Checked";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(717, 264);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column1;
private System.Windows.Forms.Button button3;
}
}
does anyone has an idea concerning the webbrowser component that always print jqplot graphs with a weird offset ?
This very simple exemple loading a jqplot exemple page in a webbrowser component, showes the page correctly, but when you try to print it you get an offset in the graph only.
The same web page show and print correctly from within IE !
I also tryied this exemple programed in Delphi2007 and DelphiXE3 and got exactly the same results.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace testwebbrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
wb.Navigate("http://www.jqplot.com/tests/bar-charts.php");
}
private void button2_Click(object sender, EventArgs e)
{
wb.ShowPrintPreviewDialog();
}
}
}
Form1.Designer.cs
namespace testwebbrowser
{
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>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.wb = new System.Windows.Forms.WebBrowser();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.button1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(597, 71);
this.panel1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(93, 12);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// wb
//
this.wb.Dock = System.Windows.Forms.DockStyle.Fill;
this.wb.Location = new System.Drawing.Point(0, 71);
this.wb.MinimumSize = new System.Drawing.Size(20, 20);
this.wb.Name = "wb";
this.wb.Size = new System.Drawing.Size(597, 370);
this.wb.TabIndex = 1;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(597, 441);
this.Controls.Add(this.wb);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.WebBrowser wb;
}
}
I'm trying to do something that i would think to be rather simple. I have 2 toolstrip items.
test1: ToolStripMenuItem which should show panel -> test_panel_1
test2: ToolStripMenuItem which should show panel -> panel1
test_panel_1 contains button -> panel_1_button1 which should hide test_panel_1 and show test_panel_2
panel1 contains button -> button1 which should hide test_panel2 and then show panel2
However, when I run the code and click on test1ToolStripMenuItem it shows test_panel_1 like it's supposed to, then when i click on panel_1_button_1 it just clears test_panel_1 and doesn't show test_panel_2. And regardless of what I click first, test2ToolStripMenuItem doesn't show panel1 at all.
Here's my code...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace panel_test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel_1_button1_Click(object sender, EventArgs e)
{
test_panel2.Visible = true;
test_panel_1.Visible = false;
}
private void test1ToolStripMenuItem_Click(object sender, EventArgs e)
{
test_panel_1.Visible = true;
panel1.Visible = false;
}
private void button1_click(object sender, EventArgs e)
{
test_panel_1.Visible = false;
test_panel2.Visible = true;
}
private void test2ToolStripMenuItem_Click(object sender, EventArgs e)
{
test_panel2.Visible = false;
panel1.Visible = true;
}
private void button1_Click_1(object sender, EventArgs e)
{
this.panel1.Visible = false;
this.panel2.Visible = true;
}
}
}
and, not sure if this helps, but...
namespace panel_test
{
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>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test_panel_1 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.test_panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.panel_1_button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.test_panel_1.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.test_panel2.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.testToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(467, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// testToolStripMenuItem
//
this.testToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.test1ToolStripMenuItem,
this.test2ToolStripMenuItem,
this.test3ToolStripMenuItem});
this.testToolStripMenuItem.Name = "testToolStripMenuItem";
this.testToolStripMenuItem.Size = new System.Drawing.Size(38, 20);
this.testToolStripMenuItem.Text = "test";
//
// test1ToolStripMenuItem
//
this.test1ToolStripMenuItem.Name = "test1ToolStripMenuItem";
this.test1ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test1ToolStripMenuItem.Text = "test1";
this.test1ToolStripMenuItem.Click += new System.EventHandler(this.test1ToolStripMenuItem_Click);
//
// test2ToolStripMenuItem
//
this.test2ToolStripMenuItem.Name = "test2ToolStripMenuItem";
this.test2ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test2ToolStripMenuItem.Text = "test2";
this.test2ToolStripMenuItem.Click += new System.EventHandler(this.test2ToolStripMenuItem_Click);
//
// test3ToolStripMenuItem
//
this.test3ToolStripMenuItem.Name = "test3ToolStripMenuItem";
this.test3ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test3ToolStripMenuItem.Text = "test3";
//
// test_panel_1
//
this.test_panel_1.Controls.Add(this.test_panel2);
this.test_panel_1.Controls.Add(this.panel_1_button1);
this.test_panel_1.Controls.Add(this.label1);
this.test_panel_1.Location = new System.Drawing.Point(44, 28);
this.test_panel_1.Name = "test_panel_1";
this.test_panel_1.Size = new System.Drawing.Size(442, 317);
this.test_panel_1.TabIndex = 1;
this.test_panel_1.Visible = false;
//
// panel1
//
this.panel1.Controls.Add(this.button1);
this.panel1.Location = new System.Drawing.Point(218, 187);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(328, 318);
this.panel1.TabIndex = 1;
this.panel1.Visible = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(86, 155);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "panel 3 to 4";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// panel2
//
this.panel2.Controls.Add(this.panel1);
this.panel2.Controls.Add(this.label3);
this.panel2.Location = new System.Drawing.Point(95, 194);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(398, 260);
this.panel2.TabIndex = 1;
this.panel2.Visible = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(86, 118);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(71, 13);
this.label3.TabIndex = 0;
this.label3.Text = "this is panel 4";
//
// test_panel2
//
this.test_panel2.Controls.Add(this.panel2);
this.test_panel2.Controls.Add(this.label2);
this.test_panel2.Location = new System.Drawing.Point(154, 101);
this.test_panel2.Name = "test_panel2";
this.test_panel2.Size = new System.Drawing.Size(358, 237);
this.test_panel2.TabIndex = 3;
this.test_panel2.Visible = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(70, 118);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 0;
this.label2.Text = "this is panel 2";
//
// panel_1_button1
//
this.panel_1_button1.Location = new System.Drawing.Point(86, 155);
this.panel_1_button1.Name = "panel_1_button1";
this.panel_1_button1.Size = new System.Drawing.Size(75, 23);
this.panel_1_button1.TabIndex = 2;
this.panel_1_button1.Text = "button1";
this.panel_1_button1.UseVisualStyleBackColor = true;
this.panel_1_button1.Click += new System.EventHandler(this.panel_1_button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(28, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(42, 13);
this.label1.TabIndex = 0;
this.label1.Text = "panel 1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(467, 357);
this.Controls.Add(this.test_panel_1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.test_panel_1.ResumeLayout(false);
this.test_panel_1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.test_panel2.ResumeLayout(false);
this.test_panel2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test3ToolStripMenuItem;
private System.Windows.Forms.Panel test_panel_1;
private System.Windows.Forms.Panel test_panel2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button panel_1_button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
}
}
I've toyed with Usercontrols a little, and i like the way i can edit and view them much better than panels; however, i don't know how to control hiding and showing them.
Thanks for the help. I know this must be coding 101, but it's something i haven't quite fully figured out yet.
It looks like your test_panel_2 is a child of test_panel_1. panel1 is a child of panel2. This is likely not what you intended. What's happening is that, because test_panel_2 is inside test_panel_1, hiding test_panel_1 also hides test_panel_2. There's a hierarchy there.
There's one or two spots where you set the visibility to false again - I'm not sure if those are correct.