[c#-windows form]多栏列表框......? [英] [c#-windows form] multi column list box...?

查看:110
本文介绍了[c#-windows form]多栏列表框......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要与多列列表框相似的东西。我需要从用户选择的内容中获取某些值。如果列表中的项目文本说明了

smith john 99999 96f

我将需要获得99999部分。我可以简单地替换空间并将它们放入一个数组中,然而,我使用的数据中的某些人在姓氏中有空格,因此您最终得到了额外的空间。例如:

al capone john 99999 96f


其中99999曾经是数组[2]现在是数组[3]

i当然可以包含一个for循环来检测整数,但是这会产生极其混乱的代码,如果有些麻烦可能会导致很多错误。


所以我需要像这个例如

展开 | 选择 | Wrap | 行号

解决方案

使用数据源。

你可以创建一个包含所有信息的DataTable,然后将其设置为数据源列表框。

设置DisplayMember =" Username" (或者你想让他们看到的任何你想要的列)

设置ValueMember =" ID" (或者你用整数来称之为列的那个)


这听起来就像我正在寻找的那样..我已经到位的数据表(已经包含了信息)不是似乎出现在我的列表框数据源属性框中。 ......可能与visual studio 2003有关...但我会去研究它。如果你有任何想法让我知道。


非常感谢,

Piercy


你将不得不这样做leg自己从数据库创建数据源(我认为)

我从来没有使用过UI DataSource,因此我不知道你能做什么,不能用它做什么

i need something simmilar to a multi column listbox. i need to get certain values back form what the user selects. ofr instance if the text of the items in the list say
smith john 99999 96f
i would need to get the 99999 part. i could simply replace the space and put them into a array however, some people in the data im using have spaces in surnames so you then end up with and extra space. example:
al capone john 99999 96f

where 99999 used to be array[2] it is now array[3]
i could of course include a for loop to detect for integers but this would make for extremly messy code and if someting goes worng it could cause a lot of errors.

so i need something like this for instance

Expand|Select|Wrap|Line Numbers

解决方案

Use a DataSource.
You can create a DataTable with all your information and then set it as the datasource for the listbox.
Set the DisplayMember ="Username" (or whatever you called the column you want them to see)
Set the ValueMember ="ID" (or whatever you called the column with your integer number)


thats sounds like exactly what im looking for however.. the datatable i already have in place (which does already contain the info) doesnt seem to show up in my listbox datasource properties box. ... could be something to do with visual studio 2003... but im going to look into it. if you got any ideas let me know.

Many thanks,
Piercy


You will have to do the leg work yourself in creating the datasource from the database (I think)
I''ve never used the UI DataSource thinger so I don''t know what you can and cannot do with it


这篇关于[c#-windows form]多栏列表框......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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