隐藏组合框的最后一个元素 [英] hide the last element of combobox

查看:68
本文介绍了隐藏组合框的最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过向导我将我的组合框绑定到数据库列,但我不想显示我的列的最后一个元素(最后一行)。请帮助

通过编程我不知道如何绑定组合框。请回答这个问题; - )

By wizard i bind my combobox to database column but i dont want to show last element of my column(last row).please help
Through programing i dont know how to bind combobox. please answer this too;-)

推荐答案

要通过代码绑定组合框 - 你可以这样做:



combobox.datasource = yourdata;

combobox.DataValueField =FieldFromYourDataToReturn;

combobox.DataTextField =FieldFromYourDataToShow;





要不显示元素 - 您可以像下面一样删除它:

combobox.Items.RemoveAt(combobox.Items.Count-1 );

或者你可以确保它从未被选中 - 这可能是一个更好的解决方案。
To bind the combobox through code - you would do something like:

combobox.datasource = yourdata;
combobox.DataValueField = "FieldFromYourDataToReturn";
combobox.DataTextField = "FieldFromYourDataToShow";


To not show an element - you could just remove it like below:
combobox.Items.RemoveAt(combobox.Items.Count-1);
Or you could make sure that it was never selected - which would probably be a better solution.


这篇关于隐藏组合框的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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