I have a mdi where i have several line of code like the given below. Only chage is Form object which is being opened. So I want to all this work using only single function defination. When I tries to capture sender it gives me ToolStipMenuItem here. But I want its sender to be form name so that I can open its corresponding form.
private void purchaseInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.PurchaseInvoice purinv = new DigitalInvy.Forms.PurchaseInvoice();
purinv.Show();
}
private void lederGroupsToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.LedgerGroup lgrp = new DigitalInvy.Forms.LedgerGroup();
lgrp.Show();
}
private void voucherEntryToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.VoucherEntry ventry = new DigitalInvy.Forms.VoucherEntry();
ventry.Show();
}
private void currencyToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.CurrencyMaster currency = new DigitalInvy.Forms.CurrencyMaster();
currency.Show();
}
private void countryToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.CountryMaster country = new DigitalInvy.Forms.CountryMaster();
country.Show();
}
I Want to do it something like this
private void cMenuItem_Click(object sender, EventArgs e)
{
if(sender.GetType()==Form)
{
Forms.CountryMaster country = new DigitalInvy.Forms.CountryMaster();
country.Show();
}
}