/// /// File itemDialog.cs /// An insertion and update modal dialog for the ListView example. /// Mike Barnes 11/30/02 /// using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace ListView { /// /// Display a dialog for adding and editing list items. /// TextBoxes are used for entering or editing values for: /// Calories, Fat Calories, and Item Description. ///
/// Tab stops have been set for the 3 TextBoxes. ///
/// Click OK to accept the changes or use the system cancel "X" /// button to hide the itemDialog without changing values. ///
public class ItemDialog : System.Windows.Forms.Form { private System.Windows.Forms.TextBox calorieTextBox; private System.Windows.Forms.Label calorieLabel; private System.Windows.Forms.Label fatCalorieLabel; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button okButton; private System.Windows.Forms.TextBox fatCalTextBox; private System.Windows.Forms.TextBox descriptTextBox; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public ItemDialog() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.calorieTextBox = new System.Windows.Forms.TextBox(); this.calorieLabel = new System.Windows.Forms.Label(); this.fatCalorieLabel = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.okButton = new System.Windows.Forms.Button(); this.fatCalTextBox = new System.Windows.Forms.TextBox(); this.descriptTextBox = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // calorieTextBox // this.calorieTextBox.Location = new System.Drawing.Point(16, 40); this.calorieTextBox.Name = "calorieTextBox"; this.calorieTextBox.Size = new System.Drawing.Size(72, 20); this.calorieTextBox.TabIndex = 1; this.calorieTextBox.Text = ""; // // calorieLabel // this.calorieLabel.Location = new System.Drawing.Point(16, 16); this.calorieLabel.Name = "calorieLabel"; this.calorieLabel.TabIndex = 0; this.calorieLabel.Text = "Calories"; // // fatCalorieLabel // this.fatCalorieLabel.Location = new System.Drawing.Point(16, 80); this.fatCalorieLabel.Name = "fatCalorieLabel"; this.fatCalorieLabel.Size = new System.Drawing.Size(88, 24); this.fatCalorieLabel.TabIndex = 0; this.fatCalorieLabel.Text = "Fat Calories"; // // label2 // this.label2.Location = new System.Drawing.Point(16, 144); this.label2.Name = "label2"; this.label2.TabIndex = 0; this.label2.Text = "Item Description"; // // okButton // this.okButton.Location = new System.Drawing.Point(80, 208); this.okButton.Name = "okButton"; this.okButton.TabIndex = 4; this.okButton.Text = "OK"; this.okButton.Click += new System.EventHandler(this.okButton_Click); // // fatCalTextBox // this.fatCalTextBox.Location = new System.Drawing.Point(16, 104); this.fatCalTextBox.Name = "fatCalTextBox"; this.fatCalTextBox.Size = new System.Drawing.Size(72, 20); this.fatCalTextBox.TabIndex = 2; this.fatCalTextBox.Text = ""; // // descriptTextBox // this.descriptTextBox.Location = new System.Drawing.Point(16, 168); this.descriptTextBox.Name = "descriptTextBox"; this.descriptTextBox.Size = new System.Drawing.Size(200, 20); this.descriptTextBox.TabIndex = 3; this.descriptTextBox.Text = ""; // // ItemDialog // this.AcceptButton = this.okButton; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(240, 245); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.descriptTextBox, this.fatCalTextBox, this.okButton, this.label2, this.fatCalorieLabel, this.calorieLabel, this.calorieTextBox}); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ItemDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Item Dialog"; this.ResumeLayout(false); } #endregion /// /// Clear the values of three TextBoxes before adding an item. /// public void clear() { calorieTextBox.Text = ""; fatCalTextBox.Text = ""; descriptTextBox.Text = ""; } // Properties for row in list view public string Calories { get { return calorieTextBox.Text; } set { calorieTextBox.Text = value;} } public string FatCals { get { return fatCalTextBox.Text; } set { fatCalTextBox.Text = value; } } public string Description { get { return descriptTextBox.Text; } set { descriptTextBox.Text = value;} } /// /// Set DialogResult to OK and hide the itemDialog. /// /// /// private void okButton_Click(object sender, System.EventArgs e) { DialogResult=DialogResult.OK; Hide(); } } }