列表框查询 [英] listbox query

查看:73
本文介绍了列表框查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...... net的新手,我需要你们所有人的帮助..我如何用另一个表中的数据填充列表框,并在列表框中选择多个项目之后..我想将选定的项目保存到数据库中.如果我们从列表框中选择多个项目,则应将其存储在数据库中,并用逗号分隔..
thanx

Hi Everyone.....am new to .net and i need some help from you all..how can i populate the listbox with data from another table and after selecting more than one item in listbox..i want to save the selected items into the database.if we select more than one items from listbox it should be stored in the database seperated by commas..
thanx

推荐答案

这个问题的基本答案是,编写一些代码.如果您不知道如何开始,那么我真的不知道该如何回答您,并希望您理解答案.您可以逐行或从数据源填充列表框.您可以遍历所选项目,并随心所欲地对其进行操作.确实,您需要阅读基础书籍或其他内容,然后尝试尝试并提出一些具体问题,因为事实如此,答案必须含糊不清,因为问题含糊不清,而且答案如此简单,以至于让我们想知道为什么您会还没有花心去阅读帮助,做一些研究等等,以及为什么要尝试既简单又又不怎么做的任务?
The basic answer to this question is, write some code. If you have no idea how to start, I don''t really know how to answer you, and expect you to understand the answer. You can populate a listbox row by row, or from a data source. You can iterate over your selected items and do whatever you want with them. Really, you need to read a basic book or something and attempt this and ask specific questions, as it stands, the answers have to be vague, as the question is vague, and the answers are so straightforward as to leave us wondering why you''ve not bothered to read the help, do some research, etc, and why you''re attempting a task that''s both straightforward, and yet you have no idea how to do it ?


这并不困难.这是我的概念:

1.声明列表框.
It''s not that difficult. Here''s my concept:

1. Declaration of ListBox.
<ListBox SelectionMode="Multiple" x:Name="xList"/>


重要的是设置SelectionMode.

2.然后在ButtonClick上创建并保存字符串.没什么好说的:


The important thing is setting SelectionMode.

2. Then creating and saving the string on ButtonClick. Nothing sophisticated here just:

string s="";
foreach(System.Windows.Controls.ListBoxItem li in xList.SelectedItems)
{
   s+= (li.Content as (whatever object youre binding here)).(Field you need to save);
   s+=";";
}
SaveToDB(s);


这篇关于列表框查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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