J
Jlaz
I am new to C# and I am writing a small Windows app that consists of a Label
and Button. I've written code that displays the following in the Label:
---- ----
2004 $1,200.00
2005 $1,260.00
2006 $1,323.00
2007 $1,389.15
2008 $1,458.61
2009 $1,531.54
2010 $1,608.12
2011 $1,688.53
2012 $1,772.96
2013 $1,861.61
2014 $1,954.69
I need it to display the heading as well without having to create a second
label to produce the "Year Rent":
Year Rent
---- ----
2004 $1,200.00
2005 $1,260.00
2006 $1,323.00
2007 $1,389.15
2008 $1,458.61
2009 $1,531.54
2010 $1,608.12
2011 $1,688.53
2012 $1,772.96
2013 $1,861.61
2014 $1,954.69
My Code is the following:
private void btnExecute_Click(object sender, System.EventArgs e)
{
int iYear = 2004, iFinalYear = 2014;
decimal mRent = 1200, mIncrease = 5.0m;
label1.Text = "Year Rent\r\n";
label1.Text = "---- ----\n";
while (iYear <= iFinalYear)
{
label1.Text += iYear + " " + mRent.ToString( "C") + "\n";
mRent *= (1 + mIncrease / 100);
mRent = Decimal.Round(mRent, 2);
iYear++;
}
}
Question1: How do I get the heading to show?
Question2: How can I display this same info in a Grid?
Thanx
and Button. I've written code that displays the following in the Label:
---- ----
2004 $1,200.00
2005 $1,260.00
2006 $1,323.00
2007 $1,389.15
2008 $1,458.61
2009 $1,531.54
2010 $1,608.12
2011 $1,688.53
2012 $1,772.96
2013 $1,861.61
2014 $1,954.69
I need it to display the heading as well without having to create a second
label to produce the "Year Rent":
Year Rent
---- ----
2004 $1,200.00
2005 $1,260.00
2006 $1,323.00
2007 $1,389.15
2008 $1,458.61
2009 $1,531.54
2010 $1,608.12
2011 $1,688.53
2012 $1,772.96
2013 $1,861.61
2014 $1,954.69
My Code is the following:
private void btnExecute_Click(object sender, System.EventArgs e)
{
int iYear = 2004, iFinalYear = 2014;
decimal mRent = 1200, mIncrease = 5.0m;
label1.Text = "Year Rent\r\n";
label1.Text = "---- ----\n";
while (iYear <= iFinalYear)
{
label1.Text += iYear + " " + mRent.ToString( "C") + "\n";
mRent *= (1 + mIncrease / 100);
mRent = Decimal.Round(mRent, 2);
iYear++;
}
}
Question1: How do I get the heading to show?
Question2: How can I display this same info in a Grid?
Thanx