VS 2008中带空格的组合框 [英] combobox with spaces in VS 2008
问题描述
关于在Visual Studio 2008(C#)中设计组合框,我有几个问题.1)我有一个组合框(名字+姓氏)数据源-SQL表.在组合框,将在格式化看起来不错,但下拉列表中选择这个名字的时候,我看到与尾随空格them.Is的名字中有一个方法可以让我修剪这些并将其设置为像一个下拉列表的工作. 2)我想在组合框中使用空格或其他文本作为第一个值.我尝试在ListItem Collection编辑器中添加值.但是这似乎仅在Dropbox中起作用,而在组合框中不起作用.预先感谢您的帮助.
I have a couple of questions in regards to designing a combobox in Visualstudio 2008(C#) 1)I have a combobox(Firstname+Lastname) datasource-SQL table. On the dropdown of the combobox, the formating looks fine, but when the name is selected,I see that the names with the trailing spaces in between them.Is there a way I can trim these and set it to work like a dropdown list. 2) I would like to have the first value in the combobox as spaces or someother text.I tried adding values in the ListItem Collection editor.but this seemed to work only in a dropbox and not in the combobox. Thanks in advance for your help.
推荐答案
您好,
如果要将SQL中的数据检索到组合框中,则需要在查询中设置其格式.
例如:
从客户中选择Rtrim(ltrim(firstname))+''''+ Rtrim(ltrim(surname))作为名称
然后,将名称绑定到您的组合框
Hi,
If you want to retrieve your data from SQL into a combo box you will need to format this in your query.
For example:
select Rtrim(ltrim(firstname))+'' '' +Rtrim(ltrim(surname)) as name from customers
Then you will bind name to your combo box
这篇关于VS 2008中带空格的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!