且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

列表框问题

更新时间:2023-11-28 21:24:34

克劳斯,


现在使用Try catch块的方式是最糟糕的方式,
>
您想创建一个不同的在我看来,这是一个简单的表格。


在这种情况下,最简单的方法是找我,

创建数据视图

设置你的distict专栏的那种

循环通过那个数据视图

每次测试前一个等于你跳过的时候你不平等

那个导入。


(顺便说一句tbpick是什么?,现在很多猜测,所以我不能

写一些示例代码)


Cor


" cjobes" < CJ **** @ nova-tech.org> schreef in bericht

新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
Claus,

The way you use now the Try catch block is the worsest way it can be,

You want to create a "distinct" table and even an easy one in my opinion.

The simplest way looks for me in this case,
Create a dataview
Set the sort of that to your distict column
Loop through that dataview
Test everytime for the earlier one when equal you skip when uneaqual you do
that import.

(what is that tbpick by the way?, it is a lot of guessing now, so I cannot
write some sample code)

Cor

"cjobes" <cj****@nova-tech.org> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
大家好,

我需要从表列填充列表框。该列有多个用户名条目,我需要提取一组唯一的用户名。

是在运行时创建的无类型数据集的一部分。没有
DataAdapter。在SQL服务器上,我只需要一个唯一集,但在我的情况下,它似乎不是一个选项。所以我在下面创建了代码。它可以工作,但是显示列表框非常慢。是否有更好的方式来完成这个?
此外,在显示列表框后,我如何捕获
用户突出显示的用户名?他/她点击一个名为doIt的按钮。

Public Sub selList()

Dim dcPick As New DataColumn(" User",GetType(String))
dcPick.Unique = True
tbPick.Columns.Add(dcPick)

Dim pRows()As DataRow = _dt.Select()
Dim pSel As DataRow 尝试
tbPick.ImportRow(pSel)
赶上
退出试试
结束尝试
下一页
结束子

感谢您的帮助,

Claus
Hi all,

I need to populate a listbox from a table column. The column has multiple
entries of usernames and I need to pull a unique set of usernames. The
table
is part of an untyped Dataset that is created during runtime. There is no
DataAdapter. On an SQL server I would just pull a Unique Set but that
doesn''t seem to be an option in my case. So I created the code below. It
works but it is very slow bringing up the list box. Is there a better way
of
doing this?
Also, after the listbox is displayed how can I capture which username(s)
the
user has highlighted when he/she clicks on a button called "doIt".

Public Sub selList()

Dim dcPick As New DataColumn("User", GetType(String))
dcPick.Unique = True
tbPick.Columns.Add(dcPick)

Dim pRows() As DataRow = _dt.Select()
Dim pSel As DataRow
For Each pSel In pRows
Try
tbPick.ImportRow(pSel)
Catch
Exit Try
End Try
Next
End Sub

Thanks for your help,

Claus



Hi Cor,


新的我最终会得到最糟糕的解决方案* G *。 VB.Net是一个痛苦的

学习经验。


tbPick是我创建的临时表,目的是获得独特的

用户名集。因为我在不同的潜艇中使用它,我在表格级别上调暗了它。这就是你在代码中看不到它的原因。我需要在程序运行期间捕获

可能的用户名列表以供重用。

用户应选择一个或多个用户并运行Select (其中

用户名等于...对另一个表格。


在另一个子目录中,我将列表框设置为:

Me.pickBox.DataSource = tbPick

Me.pickBox.DisplayMember =" User"


我也不知道我怎么能在他/她点击开始按钮之前,抓住用户选择的用户




谢谢,

Claus

Cor Ligthert< no ************ @ planet.nl>在留言中写道

news:eL * ************* @ TK2MSFTNGP15.phx.gbl ...
Hi Cor,

I new I would end up with the worst solution *G*. VB.Net is a painful
learning experience.

tbPick is a temp table that I create for the purpose of getting the unique
set of usernames. Because I use it in different subs I dimmed it at the form
class level. That''s why you don''t see it in the code. I need to catch the
list of possible usernames for the duration of the program run for reuse.
The user is supposed to select one or more users and I run a Select (where
username(s) equal... against another table.

In another sub I have set the listbox to:
Me.pickBox.DataSource = tbPick
Me.pickBox.DisplayMember = "User"

I also haven''t figured out how I can catch which user(s) the user selects
before he/she hits the "go" button.

Thanks,
Claus
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eL**************@TK2MSFTNGP15.phx.gbl...
克劳斯,

现在使用Try catch块的方法是最糟糕的方式,

在我看来,你想创建一个独特的表格,甚至是一个简单的表格。

最简单的方法是寻找m e在这种情况下,
创建数据视图
设置到您的distict列的那种类型
循环通过该数据视图
每次测试对于较早的那个,等于当你不平等时跳过
做那个导入。

(顺便说一句tbpick是什么?,现在很多猜测,所以我不能写一些示例代码)

Cor

" cjobes" &LT; CJ **** @ nova-tech.org&GT; schreef in bericht
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
Claus,

The way you use now the Try catch block is the worsest way it can be,

You want to create a "distinct" table and even an easy one in my opinion.

The simplest way looks for me in this case,
Create a dataview
Set the sort of that to your distict column
Loop through that dataview
Test everytime for the earlier one when equal you skip when uneaqual you do that import.

(what is that tbpick by the way?, it is a lot of guessing now, so I cannot
write some sample code)

Cor

"cjobes" <cj****@nova-tech.org> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
大家好,

我需要从表格列填充列表框。该列有
多个用户名条目,我需要提取一组唯一的用户名。

是在运行时创建的无类型数据集的一部分。有
没有DataAdapter。在SQL服务器上,我只需要一个唯一集,但在我的情况下,它似乎不是一个选项。所以我在下面创建了代码。它可以工作,但是显示列表框非常慢。有没有比这更好的
方式呢?
此外,在显示列表框后,如何捕获
用户突出显示的用户名?他/她点击一个名为doIt的按钮。

Public Sub selList()

Dim dcPick As New DataColumn(" User",GetType(String))
dcPick.Unique = True
tbPick.Columns.Add(dcPick)

Dim pRows()As DataRow = _dt.Select()
Dim pSel As DataRow 尝试
tbPick.ImportRow(pSel)
赶上
退出试试
结束尝试
下一页
结束子

感谢您的帮助,

Claus
Hi all,

I need to populate a listbox from a table column. The column has multiple entries of usernames and I need to pull a unique set of usernames. The
table
is part of an untyped Dataset that is created during runtime. There is no DataAdapter. On an SQL server I would just pull a Unique Set but that
doesn''t seem to be an option in my case. So I created the code below. It
works but it is very slow bringing up the list box. Is there a better way of
doing this?
Also, after the listbox is displayed how can I capture which username(s)
the
user has highlighted when he/she clicks on a button called "doIt".

Public Sub selList()

Dim dcPick As New DataColumn("User", GetType(String))
dcPick.Unique = True
tbPick.Columns.Add(dcPick)

Dim pRows() As DataRow = _dt.Select()
Dim pSel As DataRow
For Each pSel In pRows
Try
tbPick.ImportRow(pSel)
Catch
Exit Try
End Try
Next
End Sub

Thanks for your help,

Claus



>

克劳斯,


这是你想要的东西


\\\

Private Sub Form12_Load(ByVal sender As Object,_

ByVal e As System.EventArgs)处理我的Base.Load

''创建一个非常简单的数据表

Dim dt As New DataTable

dt.Columns.Add(" user")

Dim names()As String = New String(){" Geoff"," Cor",_

" Herfried"," Jay"," ; Herfried"}

For Each usern As String In Name

Dim dr As DataRow = dt.NewRow

dr(0)= usern

dt.Rows.Add(dr)

下一页

''样本不同

Dim dtclone As DataTable = dt .Clone

Dim dv As New DataView(dt)

dv.Sort =" user"

Dim myselold As String ="" ;

对于i as Integer = 0到dv.Count - 1

如果myselold<> dv(i)(" user")。ToString然后

Dim drn As DataRow = dtclone.NewRow

for y As Integer = 0 to drn.ItemArray.Length - 1

drn(y)= dv(i)(y)

下一页

myselold = dv(i)(" user) .ToString

dtclone.Rows.Add(drn)

结束如果

下一页

ListBox1.DataSource = dtclone

ListBox1.DisplayMember =" user"

''One Herfried就够了

End Sub

// /


我希望这有帮助吗?


Cor

" cjobes" < cj **** @ nova-tech.org>
Claus,

Is this something you want to archieve

\\\
Private Sub Form12_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
''creating a very simple datatable
Dim dt As New DataTable
dt.Columns.Add("user")
Dim names() As String = New String() {"Geoff", "Cor", _
"Herfried", "Jay", "Herfried"}
For Each usern As String In names
Dim dr As DataRow = dt.NewRow
dr(0) = usern
dt.Rows.Add(dr)
Next
''sample distinct
Dim dtclone As DataTable = dt.Clone
Dim dv As New DataView(dt)
dv.Sort = "user"
Dim myselold As String = ""
For i As Integer = 0 To dv.Count - 1
If myselold <> dv(i)("user").ToString Then
Dim drn As DataRow = dtclone.NewRow
For y As Integer = 0 To drn.ItemArray.Length - 1
drn(y) = dv(i)(y)
Next
myselold = dv(i)("user").ToString
dtclone.Rows.Add(drn)
End If
Next
ListBox1.DataSource = dtclone
ListBox1.DisplayMember = "user"
''One Herfried is enough
End Sub
///

I hope this helps?

Cor
"cjobes" <cj****@nova-tech.org>
我新的最终解决方案是* G *。 VB.Net是一个痛苦的学习经历。

tbPick是我创建的临时表,用于获取唯一的用户名集。因为我在不同的潜艇中使用它,所以我在类级别上对它进行了调暗。这就是你在代码中看不到它的原因。我需要在程序运行期间抓住可能的用户名列表以供重用。
用户应该选择一个或多个用户并运行Select(
用户名( s)相等...对另一个表格。

在另一个子目录中,我将列表框设置为:
Me.pickBox.DataSource = tbPick
Me.pickBox.DisplayMember =&quot ;用户

在他/她点击开始按钮之前,我还没想出如何能够识别用户选择的用户。
>
谢谢,
克劳斯
Cor Ligthert< no ************ @ planet.nl>在消息中写道
新闻: eL ************** @ TK2MSFTNGP15.phx.gbl ...
I new I would end up with the worst solution *G*. VB.Net is a painful
learning experience.

tbPick is a temp table that I create for the purpose of getting the unique
set of usernames. Because I use it in different subs I dimmed it at the
form
class level. That''s why you don''t see it in the code. I need to catch the
list of possible usernames for the duration of the program run for reuse.
The user is supposed to select one or more users and I run a Select (where
username(s) equal... against another table.

In another sub I have set the listbox to:
Me.pickBox.DataSource = tbPick
Me.pickBox.DisplayMember = "User"

I also haven''t figured out how I can catch which user(s) the user selects
before he/she hits the "go" button.

Thanks,
Claus
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eL**************@TK2MSFTNGP15.phx.gbl...
克劳斯,

现在使用Try catch的方式block是最糟糕的方式,

你想在我看来创建一个独特的表格,甚至是一个简单的表格。

最简单的方式来找我在这种情况下,
创建数据视图
设置t的种类帽子到你的distict专栏
循环通过那个数据视图
每次测试时,如果等于你跳过不平等时你
Claus,

The way you use now the Try catch block is the worsest way it can be,

You want to create a "distinct" table and even an easy one in my opinion.

The simplest way looks for me in this case,
Create a dataview
Set the sort of that to your distict column
Loop through that dataview
Test everytime for the earlier one when equal you skip when uneaqual you


执行

导入。

(顺便说一下tbpick是什么?,现在很多猜测,所以我不能写一些示例代码)

Cor

  cjobes" &LT; CJ **** @ nova-tech.org&GT; schreef in bericht
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
that import.

(what is that tbpick by the way?, it is a lot of guessing now, so I
cannot
write some sample code)

Cor

"cjobes" <cj****@nova-tech.org> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
>大家好,
>
>我需要从表列填充列表框。该列有多个>用户名的条目,我需要拉一组唯一的用户名。
>表
>是运行时期间创建的无类型数据集的一部分。没有> DataAdapter的。在SQL服务器上,我只需要一个唯一集,但是
>在我的情况下,似乎不是一个选择。所以我在下面创建了代码。
>它
>有效,但是显示列表框非常慢。是否有更好的方法>
>这样做?
>此外,在显示列表框后,我如何捕获哪个
>用户名
>
>当用户点击名为doIt的按钮时,用户已突出显示。
>
> Public Sub selList()
>
> Dim dcPick As New DataColumn(User,GetType(String))
> dcPick.Unique = True
> tbPick.Columns.Add(dcPick)
>
> Dim pRows()As DataRow = _dt.Select()
> Dim pSel As DataRow
>对于每个pSel In pRows
>试试
> tbPick.ImportRow(pSel)
>抓住
>退出尝试
>结束尝试
>下一页
>结束子
>
>感谢您的帮助,
>
>克劳斯
>
>
> Hi all,
>
> I need to populate a listbox from a table column. The column has multiple > entries of usernames and I need to pull a unique set of usernames. The
> table
> is part of an untyped Dataset that is created during runtime. There is no > DataAdapter. On an SQL server I would just pull a Unique Set but that
> doesn''t seem to be an option in my case. So I created the code below.
> It
> works but it is very slow bringing up the list box. Is there a better way > of
> doing this?
> Also, after the listbox is displayed how can I capture which
> username(s)
> the
> user has highlighted when he/she clicks on a button called "doIt".
>
> Public Sub selList()
>
> Dim dcPick As New DataColumn("User", GetType(String))
> dcPick.Unique = True
> tbPick.Columns.Add(dcPick)
>
> Dim pRows() As DataRow = _dt.Select()
> Dim pSel As DataRow
> For Each pSel In pRows
> Try
> tbPick.ImportRow(pSel)
> Catch
> Exit Try
> End Try
> Next
> End Sub
>
> Thanks for your help,
>
> Claus
>
>