列表框错误? [英] Listbox bug ??

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

问题描述

大家好,


我发现当我有一个绑定到数据表的列表框时,列表框的

ClearSelected方法无法正常工作。它只是改变了选择列表框中第1项的
。再次调用ClearSelected然后

删除选择。


如果列表框未绑定,则它可以正常工作。即只需要一次调用

ClearSelected是必需的。


我尝试过使用listbox.selectedindex = -1

这有同样的效果。


其他人遇到过这个?

史蒂夫

Hi all,

I have found that when I have a listbox bound to a datatable, the
ClearSelected method of the listbox does not work properly. It just changes
the selection to item 1 in the listbox. Calling ClearSelected again then
removes the selection.

If the listbox is unbound it works correctly. ie only one call of
ClearSelected is required.

I have tried using listbox.selectedindex = -1
This has the same effect.

Anyone else encountered this ??
Steve

推荐答案

史蒂夫,


我不确定它是否是一个众所周知的错误。

您是否尝试将selectedindex设置为两次-1这主要是

解决方案。


我希望这会有所帮助,


Cor
Steve,

I am not sure however it seems one of the very well known bugs.
Did you try setting the selectedindex twice to -1 that is mostly the
solution.

I hope this helps,

Cor
我发现当我有一个绑定到数据表的列表框时,列表框的ClearSelected方法无法正常工作。只需
就可以将选择更改为列表框中的第1项。再次调用ClearSelected然后
删除选择。

如果列表框未绑定,它可以正常工作。即只需要一次
ClearSelected调用。

我尝试过使用listbox.selectedindex = -1
这也有同样的效果。

任何人否则遇到了这个?
Steve
I have found that when I have a listbox bound to a datatable, the
ClearSelected method of the listbox does not work properly. It just changes the selection to item 1 in the listbox. Calling ClearSelected again then
removes the selection.

If the listbox is unbound it works correctly. ie only one call of
ClearSelected is required.

I have tried using listbox.selectedindex = -1
This has the same effect.

Anyone else encountered this ??
Steve



2004年8月14日星期六12:46:44 +0200,Cor Ligthert < no ********** @ planet.nl>

写道:
On Sat, 14 Aug 2004 12:46:44 +0200, "Cor Ligthert" <no**********@planet.nl>
wrote:
史蒂夫,

我不确定它是否是一个众所周知的错误。
你是否尝试将selectedindex设置为-1,这主要是
解决方案。
Steve,

I am not sure however it seems one of the very well known bugs.
Did you try setting the selectedindex twice to -1 that is mostly the
solution.



嗨Cor,


如果我打电话给他们两次,这两个选项都有效。 (即,clearselected,或

..selectedindex = -1)。麻烦的是,只有当列表框可见时,它似乎才有效。


我有一个模态对话框表单,我希望在表单<时清除选择显示br />
。我的form_load事件中的上述方法适用于在实例化之后对表单的初始

..showdialog调用,但不是在

表单被隐藏之后dialogOK /取消,然后再次使用

..showdialog调用。在后续调用中,始终选择第一个列表项

(即使在关闭时没有选择任何内容)。


我想一个选项是只需。每次通话后都会设置表格。

每次需要时都会重新创建表单,因为它在第一次通话时都能正常工作。


谢谢

Steve



Hi Cor,

Yes both options work if I call them twice. (ie either clearselected, or
..selectedindex=-1). The trouble is it only seems to work once the listbox is
visible.

I have a modal dialog form where I want the selection cleared when the form
is displayed. The above method in my form_load event works for the initial
..showdialog call of the form after it''s instantiation, but not after the
form has been hidden by dialogOK/cancel and then called again with
..showdialog. On subsequent calls the first list item is always selected
(even if there was nothing selected when it was closed).

I suppose one option would be to just .dispose the form after each call and
recreate it each time I need it, seeing as it works on the first call.

thanks
Steve


Steve,


您可能在加载事件中有代码。

你可以在写完之后把它带到New Sub。

''在InitializeComponent()调用后添加任何初始化


我试过了,而且它对我有用,在加载事件中,我得到了与你一样的问题。


我希望这有帮助吗?


Cor
Steve,

Probably you have your code in the load event.
Can you bring that to the New Sub after there where is written.
''Add any initialization after the InitializeComponent() call

I tried it, and than it works for me, in the load event I get the same
problem as you.

I hope this helps?

Cor
2004年8月14日星期六12:46:44 +0200,Cor Ligthert
< no ********** @ planet.nl>写道:
On Sat, 14 Aug 2004 12:46:44 +0200, "Cor Ligthert" <no**********@planet.nl> wrote:
史蒂夫,

我不确定它是否是一个众所周知的错误。
您是否尝试过两次设置selectedindex到-1这主要是
解决方案。
你好Cor,

是的,如果我两次打电话,这两个选项都有效。 (即清除选择,或
。选择索引= -1)。麻烦的是,一旦列表框
Steve,

I am not sure however it seems one of the very well known bugs.
Did you try setting the selectedindex twice to -1 that is mostly the
solution.
Hi Cor,

Yes both options work if I call them twice. (ie either clearselected, or
.selectedindex=-1). The trouble is it only seems to work once the listbox



可见,它似乎才能工作。

我有一个模态对话框表单,我希望在$ b时清除选择显示$ b表格。我的form_load事件中的上述方法适用于在实例化后对表单的初始
.showdialog调用,但是在
表单被dialogOK / cancel隐藏后再用
.showdialog。在随后的调用中,始终选择第一个列表项
(即使在关闭时没有选择任何内容)。

我想一个选项就是在每个调用后调用表单。
并在每次需要时重新创建它,看它是否在第一次调用时工作。

感谢
Steve


is visible.

I have a modal dialog form where I want the selection cleared when the form is displayed. The above method in my form_load event works for the initial
.showdialog call of the form after it''s instantiation, but not after the
form has been hidden by dialogOK/cancel and then called again with
.showdialog. On subsequent calls the first list item is always selected
(even if there was nothing selected when it was closed).

I suppose one option would be to just .dispose the form after each call and recreate it each time I need it, seeing as it works on the first call.

thanks
Steve



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

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