使用MultiListBox时出现问题 [英] Problem using MultiListBox

查看:63
本文介绍了使用MultiListBox时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我使用MultiListBox,但遇到问题

当我选择控件中的任何元素时,下一步,我在naviBands上导航
该应用程序崩溃了,并显示了一条错误消息.

错误图像如下:



http://img208.imageshack.us/img208/2898/errormultilistbox1.jpg[^]

当我从naviBands导航时,MultiListBox的行为是正确的,但是
当我单击MultiListBox的任何元素,然后我再次导航到naviBand,
然后出现一条错误消息.
"

我使用的一部分代码是:

Hello everyone,

I working with MultiListBox but I have a problem

when I select any element in the control, and next step I navigate on my naviBands
the application collapsed and show me an error message.

the image of error is the following:



http://img208.imageshack.us/img208/2898/errormultilistbox1.jpg[^]

"when I navigate from the naviBands the behaviour of MultiListBox is correct, But
when I clicked of any element of MultiListBox and next I navigate again form the naviBand,
then One Error Message Appear.
"

and A part of code that i using is:

string sqlqwery = "select vehiculos.cod as codigo,nombre as Nombre from vehiculos,socio where vehiculos.cod_so=socio.cod order by vehiculos.cod asc;";
DataSet myDs = new DataSet();
conexion con = new conexion();
myDs = con.consulta(sqlqwery);
this.multiColumnListBox1.DataBindings.Clear();
this.multiColumnListBox1.DataSource = myDs.Tables[0];
myDs.Dispose();



请我帮忙

预先感谢,

[修改:刚刚修复了一些严重的拼写错误...]



Please I need your help

Thanks in advance,

[Modified: just fixed a couple of egregious spelling errors...]

推荐答案

我不知道任何标准的MultiListBox控件,所以我假设它是自定义控件.

有趣的是,异常与上一行的else if语句完全相同.我猜想Count属性调用GetItemAt方法!这就是问题所在.

看来是Count方法是问题所在.
I don''t know of any standard MultiListBox control so I''m assuming its a custom control.

Interesting how the exception is exactly the same message as the else if statement on the line above. I''m guessing the Count property calls the GetItemAt method! and this is causing the problem.

It looks like it is the Count method which is the problem.


解决方案是

1)调用开始更新方法
2)用数据源填充多列表框
3)通话结束更新方法

像这样:

the solution is

1) Call begin update method
2) fill the multilistbox with datasource
3) call end update method

like this:

this.multiColumnListBox1.BeginUpdate();
                this.multiColumnListBox1.DataSource = myDs.Tables["dt"];
                this.multiColumnListBox1.EndUpdate();


这篇关于使用MultiListBox时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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