Hi,
Here is the code I have implemented:
FIRST FORM
========
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CustomFunction;
namespace MyCalculator
{
///
/// Summary description for editFormor.
///
public class Editor : Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxFunctions;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBoxFunction;
private System.Windows.Forms.DataGrid dataGridSymbolTable;
private System.Windows.Forms.TextBox textBoxResult;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox comboBoxValues;
private System.Windows.Forms.Button btnParse;
private System.Windows.Forms.Button btnEval;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox comboBoxUserFunctions;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnEdit;
private System.Windows.Forms.Button btnDelete;
private DataSet m_dataSet = new DataSet("DataSet");
private DataTable m_dataTable = new DataTable("Variables");
private Function myCustFunc = new Function();
public Function MyCustFunc
{
get { return myCustFunc; }
set { myCustFunc = value; }
}
private bool isParsed = false;
public bool IsParsed
{
get { return isParsed; }
set { isParsed = value; }
}
//DeleteForm myDeleteForm = new DeleteForm();
//EditForm myEditForm = new EditForm();
public Editor()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
DataColumn name = new DataColumn("Name",typeof(string));
DataColumn dValue = new DataColumn("Value",typeof(double));
name.ReadOnly = true;
name.AllowDBNull = false;
m_dataTable.Columns.Add(name);
m_dataTable.Columns.Add(dValue);
m_dataSet.Tables.Add(m_dataTable);
//
// 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.label1 = new System.Windows.Forms.Label();
this.textBoxFunction = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.comboBoxValues = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.comboBoxFunctions = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.btnParse = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.dataGridSymbolTable = new System.Windows.Forms.DataGrid();
this.textBoxResult = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.btnEval = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnDelete = new System.Windows.Forms.Button();
this.btnEdit = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.comboBoxUserFunctions = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridSymbolTable)).BeginInit();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(48, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(136, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Enter compound function";
//
// textBoxFunction
//
this.textBoxFunction.Location = new System.Drawing.Point(48, 72);
this.textBoxFunction.Name = "textBoxFunction";
this.textBoxFunction.Size = new System.Drawing.Size(272, 20);
this.textBoxFunction.TabIndex = 1;
this.textBoxFunction.Text = "";
this.textBoxFunction.TextChanged += new System.EventHandler(this.textBoxFunction_TextChanged);
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.Transparent;
this.groupBox1.Controls.Add(this.comboBoxValues);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.comboBoxFunctions);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.btnParse);
this.groupBox1.Controls.Add(this.btnEval);
this.groupBox1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.groupBox1.Location = new System.Drawing.Point(48, 120);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(216, 216);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Custom Functions";
//
// comboBoxValues
//
this.comboBoxValues.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxValues.Items.AddRange(new object[] {
"pi",
"e"});
this.comboBoxValues.Location = new System.Drawing.Point(16, 128);
this.comboBoxValues.Name = "comboBoxValues";
this.comboBoxValues.Size = new System.Drawing.Size(128, 22);
this.comboBoxValues.TabIndex = 3;
this.comboBoxValues.SelectedIndexChanged += new System.EventHandler(this.comboBoxValues_SelectedIndexChanged);
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 104);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(176, 16);
this.label4.TabIndex = 2;
this.label4.Text = "Choose wanted values from here";
//
// comboBoxFunctions
//
this.comboBoxFunctions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFunctions.Items.AddRange(new object[] {
"sin",
"cos",
"tan",
"cotan",
"sinh",
"cosh",
"tanh",
"cotanh",
"asin",
"acos",
"atan",
"acotan",
"abs",
"exp",
"ln",
"log10",
"log",
"sqrt"});
this.comboBoxFunctions.Location = new System.Drawing.Point(16, 64);
this.comboBoxFunctions.Name = "comboBoxFunctions";
this.comboBoxFunctions.Size = new System.Drawing.Size(128, 22);
this.comboBoxFunctions.TabIndex = 1;
this.comboBoxFunctions.SelectedIndexChanged += new System.EventHandler(this.comboBoxFunctions_SelectedIndexChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(176, 16);
this.label2.TabIndex = 0;
this.label2.Text = "Choose wanted textBoxFunctions from here";
//
// btnParse
//
this.btnParse.BackColor = System.Drawing.Color.Transparent;
this.btnParse.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnParse.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnParse.ForeColor = System.Drawing.Color.SeaGreen;
this.btnParse.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnParse.Location = new System.Drawing.Point(16, 176);
this.btnParse.Name = "btnParse";
this.btnParse.Size = new System.Drawing.Size(64, 23);
this.btnParse.TabIndex = 67;
this.btnParse.Text = "Parse";
this.btnParse.Click += new System.EventHandler(this.btnParse_Click);
//
// btnExit
//
this.btnExit.BackColor = System.Drawing.Color.Transparent;
this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnExit.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnExit.ForeColor = System.Drawing.Color.SeaGreen;
this.btnExit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnExit.Location = new System.Drawing.Point(432, 528);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(64, 23);
this.btnExit.TabIndex = 68;
this.btnExit.Text = "Exit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// dataGridSymbolTable
//
this.dataGridSymbolTable.DataMember = "";
this.dataGridSymbolTable.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridSymbolTable.Location = new System.Drawing.Point(48, 440);
this.dataGridSymbolTable.Name = "dataGridSymbolTable";
this.dataGridSymbolTable.PreferredColumnWidth = 118;
this.dataGridSymbolTable.Size = new System.Drawing.Size(272, 112);
this.dataGridSymbolTable.TabIndex = 69;
//
// textBoxResult
//
this.textBoxResult.Location = new System.Drawing.Point(48, 392);
this.textBoxResult.Name = "textBoxResult";
this.textBoxResult.Size = new System.Drawing.Size(272, 20);
this.textBoxResult.TabIndex = 70;
this.textBoxResult.Text = "";
//
// label3
//
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
this.label3.Location = new System.Drawing.Point(48, 352);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 16);
this.label3.TabIndex = 71;
this.label3.Text = "Result";
//
// btnEval
//
this.btnEval.BackColor = System.Drawing.Color.Transparent;
this.btnEval.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnEval.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnEval.ForeColor = System.Drawing.Color.SeaGreen;
this.btnEval.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnEval.Location = new System.Drawing.Point(120, 176);
this.btnEval.Name = "btnEval";
this.btnEval.Size = new System.Drawing.Size(64, 23);
this.btnEval.TabIndex = 72;
this.btnEval.Text = "Evaluate";
this.btnEval.Click += new System.EventHandler(this.btnEval_Click);
//
// groupBox2
//
this.groupBox2.BackColor = System.Drawing.Color.Transparent;
this.groupBox2.Controls.Add(this.btnDelete);
this.groupBox2.Controls.Add(this.btnEdit);
this.groupBox2.Controls.Add(this.btnSave);
this.groupBox2.Controls.Add(this.comboBoxUserFunctions);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.groupBox2.ForeColor = System.Drawing.SystemColors.ControlText;
this.groupBox2.Location = new System.Drawing.Point(288, 120);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(216, 216);
this.groupBox2.TabIndex = 73;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Edit Functions";
//
// btnDelete
//
this.btnDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDelete.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnDelete.ForeColor = System.Drawing.Color.SeaGreen;
this.btnDelete.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnDelete.Location = new System.Drawing.Point(128, 128);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(64, 23);
this.btnDelete.TabIndex = 75;
this.btnDelete.Text = "Delete";
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnEdit
//
this.btnEdit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnEdit.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnEdit.ForeColor = System.Drawing.Color.SeaGreen;
this.btnEdit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnEdit.Location = new System.Drawing.Point(72, 176);
this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new System.Drawing.Size(64, 23);
this.btnEdit.TabIndex = 74;
this.btnEdit.Text = "Edit";
this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
//
// btnSave
//
this.btnSave.BackColor = System.Drawing.Color.Transparent;
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSave.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnSave.ForeColor = System.Drawing.Color.SeaGreen;
this.btnSave.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnSave.Location = new System.Drawing.Point(16, 128);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(64, 23);
this.btnSave.TabIndex = 73;
this.btnSave.Text = "Save";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// comboBoxUserFunctions
//
this.comboBoxUserFunctions.Cursor = System.Windows.Forms.Cursors.Arrow;
this.comboBoxUserFunctions.Location = new System.Drawing.Point(16, 80);
this.comboBoxUserFunctions.Name = "comboBoxUserFunctions";
this.comboBoxUserFunctions.Size = new System.Drawing.Size(176, 22);
this.comboBoxUserFunctions.TabIndex = 1;
//
// label6
//
this.label6.Location = new System.Drawing.Point(16, 40);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(192, 16);
this.label6.TabIndex = 0;
this.label6.Text = "Save the functions you defined here";
//
// Editor
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Wheat;
this.ClientSize = new System.Drawing.Size(528, 587);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBoxResult);
this.Controls.Add(this.dataGridSymbolTable);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBoxFunction);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.Name = "Editor";
this.Text = "CompoundFunctionsCalculator";
this.Load += new System.EventHandler(this.Editor_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridSymbolTable)).EndInit();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void comboBoxFunctions_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBoxFunctions.SelectedIndex != -1)
textBoxFunction.Text += comboBoxFunctions.SelectedItem.ToString() + "(" ;
}
private void btnParse_Click(object sender, System.EventArgs e)
{
IsParsed = true;
myCustFunc.Parse(textBoxFunction.Text);
myCustFunc.InfixToPostfix();
ArrayList var = myCustFunc.Variables;
DataRow row;
m_dataTable.Rows.Clear();
foreach(Symbol sym in var)
{
row = m_dataTable.NewRow();
row["Name"] = sym.m_name;
row["Value"] = sym.m_value;
m_dataTable.Rows.Add(row);
}
dataGridSymbolTable.SetDataBinding(m_dataSet,"Variables");
}
private void btnEval_Click(object sender, System.EventArgs e)
{
if(!IsParsed)
{
MessageBox.Show("You must click the Parse button first.");
return;
}
ArrayList var = new ArrayList();
Symbol sym;
foreach(DataRow row in m_dataTable.Rows)
{
sym.m_name = (string)row["Name"];
sym.m_value = (double)row["Value"];
sym.m_type = CustomFunction.Type.Variable;
var.Add(sym);
}
myCustFunc.Variables = var;
myCustFunc.EvaluatePostfix();
if(myCustFunc.Error)
{
MessageBox.Show(myCustFunc.ErrorDescription);
return;
}
textBoxResult.Text = myCustFunc.Result.ToString();
}
private void textBoxFunction_TextChanged(object sender, System.EventArgs e)
{
IsParsed = false;
}
private void comboBoxValues_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBoxValues.SelectedIndex != -1)
textBoxFunction.Text += comboBoxValues.SelectedItem.ToString();
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Hide();
//Calculator myCalc = new Calculator();
//myCalc.Show();
}
private void btnSave_Click(object sender, System.EventArgs e)
{
Button btn = sender as Button;
if (textBoxFunction.Text == "")
MessageBox.Show("You did not provide a function expression for saving !","Attention");
else if (!IsParsed)
MessageBox.Show("You did not parse the function expression !","Attention");
else
{
SaveDeleteForm mySaveDeleteForm = new SaveDeleteForm(this);
mySaveDeleteForm.Name = btn.Text;
//mySaveDeleteForm.Visible = false;
ShowUserFunctions(mySaveDeleteForm);
}
}
private void btnDelete_Click(object sender, System.EventArgs e)
{
}
private void btnEdit_Click(object sender, System.EventArgs e)
{
Button btn = sender as Button;
if (comboBoxUserFunctions.Text == "")
MessageBox.Show("Error: You did not provide a function expression for edit !");
else
{
SaveDeleteForm mySaveDeleteForm = new SaveDeleteForm(this);
mySaveDeleteForm.Name = btn.Text;
//mySaveDeleteForm.Visible = false;
ShowUserFunctions(mySaveDeleteForm);
}
}
public void ShowUserFunctions(SaveDeleteForm mySaveDelForm)
{
if (mySaveDelForm.Name == "Save")
{
mySaveDelForm.Visible = false;
//mySaveDelForm.Close();
if (mySaveDelForm.ShowDialog() == DialogResult.OK)
{
if (!comboBoxUserFunctions.Items.Contains(mySaveDelForm.FunctionName))
comboBoxUserFunctions.Items.Add(mySaveDelForm.FunctionName);
}
}
if (mySaveDelForm.Name == "Edit")
{
mySaveDelForm.Visible = false;
//mySaveDelForm.Close();
if (mySaveDelForm.ShowDialog() == DialogResult.OK)
{
if (comboBoxUserFunctions.Items.Contains(mySaveDelForm.FunctionName))
comboBoxUserFunctions.Items.Remove(mySaveDelForm.FunctionName);
comboBoxUserFunctions.Items.Add(mySaveDelForm.FunctionName);
}
}
}
private void Editor_Load(object sender, System.EventArgs e)
{
}
}
}
SECOND FORM
==========
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace MyCalculator
{
///
/// Summary description for Save.
///
public class SaveDeleteForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox textBoxFunctionName;
public string FunctionName
{
get { return textBoxFunctionName.Text; }
set { textBoxFunctionName.Text = value; }
}
Editor myEditor = null;
public SaveDeleteForm(Editor parent)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
myEditor = parent;
//
// 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.label1 = new System.Windows.Forms.Label();
this.textBoxFunctionName = new System.Windows.Forms.TextBox();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(160, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Give a name for your function";
//
// textBoxFunctionName
//
this.textBoxFunctionName.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.textBoxFunctionName.Location = new System.Drawing.Point(24, 64);
this.textBoxFunctionName.Name = "textBoxFunctionName";
this.textBoxFunctionName.Size = new System.Drawing.Size(136, 20);
this.textBoxFunctionName.TabIndex = 1;
this.textBoxFunctionName.Text = "";
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold);
this.btnOk.ForeColor = System.Drawing.Color.ForestGreen;
this.btnOk.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnOk.Location = new System.Drawing.Point(24, 112);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(56, 23);
this.btnOk.TabIndex = 70;
this.btnOk.Text = "Ok";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold);
this.btnCancel.ForeColor = System.Drawing.Color.ForestGreen;
this.btnCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btnCancel.Location = new System.Drawing.Point(112, 112);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(56, 23);
this.btnCancel.TabIndex = 71;
this.btnCancel.Text = "Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// SaveDeleteForm
//
this.AcceptButton = this.btnOk;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Wheat;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(234, 173);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.textBoxFunctionName);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "SaveDeleteForm";
this.ResumeLayout(false);
}
#endregion
private void btnOk_Click(object sender, System.EventArgs e)
{
btnOk.DialogResult = DialogResult.OK;
myEditor.ShowUserFunctions(this);
this.Close();
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
and here is the exception I get:
System.InvalidOperationException: Forms that are already displayed modally cannot be displayed as a modal dialog. Close the form before calling showDialog.
I don't know why I get this exception. I must have done somethig wrong but I can't figure it out!
If you could just look over the code I provided and give me hint on how to fix this, I would be very grateful.
Please forgive me for posting such a large piece of code, but I thought that giving you the whole code, would help you to get the hole idea.
Any help, hint, idea very much appreciated.
Please answer as quickly as possible because without this I cannot continue the project I'm working on!
Cheers to all of you,
Adisor