How can i shorten my code for various winform calls in MDI

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-04-24T07:11:39Z Indexed on 2010/04/24 7:13 UTC
Read the original article Hit count: 469

Filed under:
|
|
|
|

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();
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms