ListView selectindex事件错误????? [英] ListView selectindex event bug?????

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

问题描述

好的,麻烦:


表格:


面具(很多文字框和......)

Listview 1作为Listview与一些项目

booEdit as boolean = False

intEditIndex as integer


场景:

- 我选择项目1

(我得到事件Listview1.SelectIndexChanged - 我加载掩码为

所选项目)

- 我去编辑所选项目的面具模式(我设置booEdit = true,

intEditIndex = Listview1.selecteditems.item(0).index)

- 我改变了面具上的一些字段

- 然后我点击其他item10(我得到活动

Listview1.SelectIndexChanged),我问自己,如果我''我正在编辑

模式然后让我保存更改...

- res = msgbox(你想保存更改吗?,yesnocancel,.. 。)

case是的:我保存了面具(对于item1),让listview1转到item10

(...加载面具...... booEdit = false。 ...)

案例编号:s是的,但是没有保存更改

case取消(麻烦):我什么也没做,除了我想要item1是

被选中。

Private Sub ListView1Ch(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Listview1.SelectedIndexChanged

如果Listview1.selecteditems.count> ; 0然后

如果me.editmode那么

Dim res As Microsoft.VisualBasic.MsgBoxResult

res = MsgBox(" Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)

如果res = msgboxresult.cancel那么

me.listview1.items(me.intEditIndex).selected = true;

结束如果

其他

loadmask(listview1.selecteditems.item(0))

结束如果

结束如果

结束子


我明白当我打电话给

''me.listview1.items(我。 intEditIndex).selected = true;''我将在事件Listview1.SelectedIndexChanged上再次通知

所以我添加了另一个布尔值来

过滤掉不需要的事件(参见booSlave) 。


Dim booSlave as boolean = false

Private Sub ListView1Ch(ByVal sender As System.Object,ByVal e As

System .EventArgs)处理Listview1.SelectedIndexChanged

如果booSlave = true则退出sub

如果Listview1.selecteditems.coun t> 0然后

如果me.editmode那么

Dim res As Microsoft.VisualBasic.MsgBoxResult

res = MsgBox(" Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)

如果res = msgboxresult.cancel那么

booSlave = true

me.listview1.items(我。 intEditIndex).selected = true;

booSlave = false

结束如果

else

loadmask(listview1.selecteditems .item(0))

结束如果

结束如果

结束子


麻烦当我在调试模式下(一步一步地做)时,一切都好了,但是当我在运行时(没有断点)时,我得到了

messagebox要我保存2次....


错误还是我的错误?

感谢您有兴趣阅读本文。


re,HaBiX

(框架1.1,vs 2003 EA,vb.net)

解决方案

< blockquote>你确定booSlave布尔值保持正确吗?我想你必须声明

它是私人的


eric


" HABJAN?iga" < habix [AT] intelcom [点] SI>在留言中写道

news:bm ******** @ enews3.newsguy.com ...

好的,麻烦:

面具(很多文本框和......)
Listview 1作为Listview的一些项目
booEdit as boolean = False
intEditIndex as整数

场景:
- 我选择第1项
(我得到事件Listview1.SelectIndexChanged - 我加载了
所选项目的面具)
- 我转到所选项目的面具编辑模式(我设置booEdit = true,
intEditIndex = Listview1.selecteditems.item(0).index)
- 我改变了面具上的一些字段
- 然后我点击其他item10(我得到活动
Listview1.SelectIndexChanged),我问自己如果我在编辑
模式然后要求我保存更改...
- res = msgbox(你要保存更改吗?,yesnocancel,...)
案例是:我保存了面具(对于item1),让listview1转到item10
( ......加载面具.... booEdit = false ....)
案例否:同样如此,但没有保存更改
案例取消(麻烦):除了我想要选择item1之外什么都不做。

Private Sub ListView1Ch( ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Listview1.SelectedIndexChanged
如果Listview1.selecteditems.count> 0然后
如果me.editmode然后
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox(" Save?",MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
如果res = msgboxresult.cancel那么
me.listview1.items(me.intEditIndex).selected = true;
结束如果
其他
loadmask(listview1.selecteditems.item(0 ))
结束如果结束如果
结束子

我明白,当我打电话给我时,我的电子邮件是
''me.listview1.items(me.intEditIndex) .selected = true;''我将在事件Listview1.SelectedIndexChanged上再次通知
所以我添加了另一个布尔值
来过滤掉不需要的事件(参见booSlave)。

昏暗booSlave as boolean = false
Private Sub ListView1Ch(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Listview1.SelectedIndexChanged
如果booSlave = true则退出sub
如果Listview1.selecteditems.count> 0然后
如果me.editmode然后
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox(" Save?",MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
如果res = msgboxresult.cancel那么
booSlave = true
me.listview1.items(me.intEditIndex).selected = true;
booSlave = false
结束如果
否则
loadmask(listview1.selecteditems.item(0))
结束如果结束如果
结束Sub

麻烦就在我的时候在调试模式下(一步一步地做)一切都好了,但是当我在运行时(没有断点)时,我得到了
消息框,要求我保存2次....错误或我的错误?
感谢您有兴趣阅读本文。

,HaBiX

(框架1.1,vs 2003 EA ,vb.net)



您好HABJAN,

如果me.editmode那么




那是什么,我没看到它作为表格的一员,但也许我看到

出了什么问题?


Cor

好的...如果有人想要'尝试它来获取来自
的源代码 http://www.intelcom.si/test.zip

点击item1(选择它)

点击编辑

然后点击第3项

best re,habix

" HABJAN?iga" < habix [AT] intelcom [点] SI>在留言中写道

news:bm ******** @ enews3.newsguy.com ...

好的,麻烦:

面具(很多文本框和......)
Listview 1作为Listview的一些项目
booEdit as boolean = False
intEditIndex as整数

场景:
- 我选择第1项
(我得到事件Listview1.SelectIndexChanged - 我加载了
所选项目的面具)
- 我转到所选项目的面具编辑模式(我设置booEdit = true,
intEditIndex = Listview1.selecteditems.item(0).index)
- 我改变了面具上的一些字段
- 然后我点击其他item10(我得到活动
Listview1.SelectIndexChanged),我问自己如果我在编辑
模式然后要求我保存更改...
- res = msgbox(你要保存更改吗?,yesnocancel,...)
案例是:我保存了面具(对于item1),让listview1转到item10
( ......加载面具.... booEdit = false ....)
案例否:同样如此,但没有保存更改
案例取消(麻烦):除了我想要选择item1之外什么都不做。

Private Sub ListView1Ch( ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Listview1.SelectedIndexChanged
如果Listview1.selecteditems.count> 0然后
如果me.editmode然后
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox(" Save?",MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
如果res = msgboxresult.cancel那么
me.listview1.items(me.intEditIndex).selected = true;
结束如果
其他
loadmask(listview1.selecteditems.item(0 ))
结束如果结束如果
结束子

我明白,当我打电话给我时,我的电子邮件是
''me.listview1.items(me.intEditIndex) .selected = true;''我将在事件Listview1.SelectedIndexChanged上再次通知
所以我添加了另一个布尔值
来过滤掉不需要的事件(参见booSlave)。

昏暗booSlave as boolean = false
Private Sub ListView1Ch(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Listview1.SelectedIndexChanged
如果booSlave = true则退出sub
如果Listview1.selecteditems.count> 0然后
如果me.editmode然后
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox(" Save?",MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
如果res = msgboxresult.cancel那么
booSlave = true
me.listview1.items(me.intEditIndex).selected = true;
booSlave = false
结束如果
否则
loadmask(listview1.selecteditems.item(0))
结束如果结束如果
结束Sub

麻烦就在我的时候在调试模式下(一步一步地做)一切都好了,但是当我在运行时(没有断点)时,我得到了
消息框,要求我保存2次....错误或我的错误?
感谢您有兴趣阅读本文。

,HaBiX

(框架1.1,vs 2003 EA ,vb.net)



Ok, the trouble:

On form:

Mask (lots of textboxes & ...)
Listview 1 as Listview with some items
booEdit as boolean=False
intEditIndex as integer

Scenario:
- i select item 1
(i get event Listview1.SelectIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selecteditems.item(0).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.SelectIndexChanged), and i ask myself in event if i''am in edit
mode then ask me to save changes...
- res = msgbox("Do you want to save changes?",yesnocancel,...)
case Yes: i save the mask (for item1) and let listview1 go to item10
(...load the mask....booEdit=false....)
case No: same as yes, but no saving the changes
case Cancel (the trouble): i do nothing except i want that item1 is
selected.

Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
me.listview1.items(me.intEditIndex).selected=true;
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

I understand that when i call
''me.listview1.items(me.intEditIndex).selected=true ;'' i will be notifyed
again on event Listview1.SelectedIndexChanged so i added another boolean to
filter out unwanted events (see the booSlave).

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
if booSlave=true then exit sub
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
booSlave=true
me.listview1.items(me.intEditIndex).selected=true;
booSlave=false
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

The trouble is when i''am in debug mode (doing it step by step) everything
turns out ok, but when i do it in runtime (no breakpoints), i get the
messagebox asking me to save 2 times....

Bug or my mistake?
Thanks for taking interest in reading this.

re, HaBiX
(framework 1.1, vs 2003 EA, vb.net)

解决方案

are you sure the booSlave boolean stays true ?? i think you have to declare
it as private

eric

"HABJAN ?iga" <habix[AT]intelcom[DOT]si> wrote in message
news:bm********@enews3.newsguy.com...

Ok, the trouble:

On form:

Mask (lots of textboxes & ...)
Listview 1 as Listview with some items
booEdit as boolean=False
intEditIndex as integer

Scenario:
- i select item 1
(i get event Listview1.SelectIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selecteditems.item(0).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.SelectIndexChanged), and i ask myself in event if i''am in edit
mode then ask me to save changes...
- res = msgbox("Do you want to save changes?",yesnocancel,...)
case Yes: i save the mask (for item1) and let listview1 go to item10
(...load the mask....booEdit=false....)
case No: same as yes, but no saving the changes
case Cancel (the trouble): i do nothing except i want that item1 is
selected.

Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
me.listview1.items(me.intEditIndex).selected=true;
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

I understand that when i call
''me.listview1.items(me.intEditIndex).selected=true ;'' i will be notifyed
again on event Listview1.SelectedIndexChanged so i added another boolean to filter out unwanted events (see the booSlave).

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
if booSlave=true then exit sub
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
booSlave=true
me.listview1.items(me.intEditIndex).selected=true;
booSlave=false
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

The trouble is when i''am in debug mode (doing it step by step) everything
turns out ok, but when i do it in runtime (no breakpoints), i get the
messagebox asking me to save 2 times....

Bug or my mistake?
Thanks for taking interest in reading this.

re, HaBiX
(framework 1.1, vs 2003 EA, vb.net)



Hi HABJAN,

if me.editmode then



What is that, I did not see it as a member of the form, but maybe I see
something wrong?

Cor


OK... if someone want''s to try it get the source code from
http://www.intelcom.si/test.zip

Click on item1 (select it)
Click on edit
Then click on item 3

best re, habix
"HABJAN ?iga" <habix[AT]intelcom[DOT]si> wrote in message
news:bm********@enews3.newsguy.com...

Ok, the trouble:

On form:

Mask (lots of textboxes & ...)
Listview 1 as Listview with some items
booEdit as boolean=False
intEditIndex as integer

Scenario:
- i select item 1
(i get event Listview1.SelectIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selecteditems.item(0).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.SelectIndexChanged), and i ask myself in event if i''am in edit
mode then ask me to save changes...
- res = msgbox("Do you want to save changes?",yesnocancel,...)
case Yes: i save the mask (for item1) and let listview1 go to item10
(...load the mask....booEdit=false....)
case No: same as yes, but no saving the changes
case Cancel (the trouble): i do nothing except i want that item1 is
selected.

Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
me.listview1.items(me.intEditIndex).selected=true;
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

I understand that when i call
''me.listview1.items(me.intEditIndex).selected=true ;'' i will be notifyed
again on event Listview1.SelectedIndexChanged so i added another boolean to filter out unwanted events (see the booSlave).

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Listview1.SelectedIndexChanged
if booSlave=true then exit sub
If Listview1.selecteditems.count > 0 then
if me.editmode then
Dim res As Microsoft.VisualBasic.MsgBoxResult
res = MsgBox("Save?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
if res = msgboxresult.cancel then
booSlave=true
me.listview1.items(me.intEditIndex).selected=true;
booSlave=false
end if
else
loadmask(listview1.selecteditems.item(0))
end if
end if
End Sub

The trouble is when i''am in debug mode (doing it step by step) everything
turns out ok, but when i do it in runtime (no breakpoints), i get the
messagebox asking me to save 2 times....

Bug or my mistake?
Thanks for taking interest in reading this.

re, HaBiX
(framework 1.1, vs 2003 EA, vb.net)



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

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