自动选择下拉列表中的项目 [英] Autoselecting an item in a dropdown list
本文介绍了自动选择下拉列表中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有一个只有一个项目(字符串)的下拉列表,则我不希望用户单击下拉列表并选择该项目,而是希望我在运行该菜单时自动选择该项目.代码.我试了好几次都没用.
If there is drop downlist with only one item ( a string ) is available in it, I dont want the user go click the drop down list and choose the item, instead I want the item to be selected autamatically when i run the code. I tried many times nothing works . what is the right c# code which can do it in asp.net.
推荐答案
在调用InitializeComponents
之后,将其放在构造函数中,或采用以下形式:的
Put this in your constructor AFTER the call to InitializeComponents
, or in the form''s
Load
事件处理程序
event handler
combobox.SelectedIndex = n;
其中"n"是要自动选择的项目的索引号.
where "n" is the index number of the item you want to automatically select.
这篇关于自动选择下拉列表中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文