DropDownList 向上显示
DropDownList Displays Upward
我认为这是一个简单的修复,但还没有遇到过。
如果空的 newListItem 是 .Selected = true
,我的下拉列表将向上而不是向下显示选项。
有没有办法让列表向下下降?
我的 SQL 语句按字母顺序排列(因此计算机在最上面)。
OracleDataAdapterAds1.Fill(DsAds, "TABLE NAME")
CategoryListBox.DataSource = DsAds
CategoryListBox.DataMember = "TABLE NAME"
CategoryListBox.DataBind()
Dim newListItem As ListItem
newListItem = New ListItem("", "")
newListItem.Selected = True
CategoryListBox.Items.Add(newListItem)
仅供参考 - 如果 .Selected = false
它们向下显示
向上时:
因为所选项目是列表中的最后一项。在顶部插入项目
CategoryListBox.Items.Insert(0, newListItem);
此外,根据您的情况,插入空项不是一个好主意,尤其是当控件是数据绑定时。
您可以像这样取消选择列表框:
CategoryListBox.SelectedIndex = -1;
我认为这是一个简单的修复,但还没有遇到过。
如果空的 newListItem 是 .Selected = true
,我的下拉列表将向上而不是向下显示选项。
有没有办法让列表向下下降?
我的 SQL 语句按字母顺序排列(因此计算机在最上面)。
OracleDataAdapterAds1.Fill(DsAds, "TABLE NAME")
CategoryListBox.DataSource = DsAds
CategoryListBox.DataMember = "TABLE NAME"
CategoryListBox.DataBind()
Dim newListItem As ListItem
newListItem = New ListItem("", "")
newListItem.Selected = True
CategoryListBox.Items.Add(newListItem)
仅供参考 - 如果 .Selected = false
它们向下显示
向上时:
因为所选项目是列表中的最后一项。在顶部插入项目
CategoryListBox.Items.Insert(0, newListItem);
此外,根据您的情况,插入空项不是一个好主意,尤其是当控件是数据绑定时。 您可以像这样取消选择列表框:
CategoryListBox.SelectedIndex = -1;