根据下拉列表填写列表 [英] Fiiling a list according to the dropdownlist

查看:72
本文介绍了根据下拉列表填写列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要获得一个下拉列表中的月份列表.我现在需要的是,如果我从下拉列表中选择了一个月,则我需要另一个列表应该包含所选月份的值加上前三个月的值.

例如:如果我从下拉列表中选择nov,则列表应包含nov,oct,sept和aug.

但是我选择了jan,那么只有jan应该填充在列表中.

该列表应为可存储月索引的整数类型.

任何人都可以帮我做这件事吗 ...它的紧迫性

Hi,

I need to get a list of months in a dropdown which i did.now what i need is if i selected one month from the dropdown i need another list should contain the selected month''s value plus the previous 3 months values .

Eg : if i select nov from dropdown the list should contain nov,oct,sept and aug.

but i select jan then only jan should get populated in the list.

The list should be of type integer which can store Month index.

Can anyone plss help me in doing this...its urgent

推荐答案

这里有一些简单的代码,您可以修改它们以获取所需的内容,只需确保您的数据源中的月份是连续的.


Here is some simple code you can modify to get what you need, just mak sure the months in you datasource are sequential.


private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
       {
           comboBox2.SelectedIndex = previousMonth(comboBox1.SelectedIndex);
           comboBox3.SelectedIndex = previousMonth(comboBox2.SelectedIndex);
           comboBox4.SelectedIndex = previousMonth(comboBox3.SelectedIndex);
       }

       private int previousMonth(int sIndex)
       {
           if (sIndex == -1) return -1;
           if (sIndex == 0) sIndex = 12;
               return sIndex - 1;
       }


这篇关于根据下拉列表填写列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆