下拉列表与财政年度绑定
问题描述:
大家好,
我需要获得一个财务年度的结果(... 2011-2012、2012-2013、2013-2014),从我给定的日期开始,一直到下拉列表中的5年.
我不知道该怎么做.我什至不知道是否可能.
任何帮助都将不胜感激.
预先感谢您,
Hi all,
I need to get a result of financial years(...2011-2012, 2012-2013, 2013-2014) starting from the date given by me to till 5 year in a dropdown list.
I have no idea of how to do this. I don''t even know whether it is possible or not.
Any kind of help would be Appreciated.
Thanking you in advance,
答
让我们说说我们从文本框中收到了给定的日期:-
Let say we received the given date from text box:-
private void button1_Click(object sender, EventArgs e)
{
DateTime GivenDate = Convert.ToDateTime(textBox1.Text);
int GivenYear = GivenDate.Year;
for(int i=0; i<5; i++)
{
comboBox1.Items.Add(GivenYear + i + "-" + (GivenYear + 1 + i));
}
}
私有无效GetFinYear(int namedYear)
{
for(int i = 1; i< = 5; i ++)
{
comboBox1.Items.Add(givenYear.toString()+-" +(GivenYear + i).toString());
++ givenYear;
}
}
private void GetFinYear(int givenYear)
{
for(int i=1; i<=5; i++)
{
comboBox1.Items.Add(givenYear.toString() + " - " + (GivenYear+i).toString());
++givenYear;
}
}