473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ListView selectindex event bug?????

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)
Nov 20 '05 #1
10 1853
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)

Nov 20 '05 #2
Cor
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
Nov 20 '05 #3
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)

Nov 20 '05 #4
dim editmode as boolean (declared in form)

i like to use word "me." because it display members so i don't have to type
a lot :o)

habix

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
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

Nov 20 '05 #5
Cor
Hi Habjan,
I tried it and then messagebox shows only one time in release mode and in
debug mode.

I don't like that index change event , I use mouse down.

But you did all that humbug to prevent that it fires too often.

I could not find it and I saw you were using the same framework and VB as I.

Maybe someone else has the same problems as you with this code.

Cor
Nov 20 '05 #6
you should be able to push ctrl+space and get the intellisense to work, once you start typing the
word.
"HABJAN ®iga" <habix[AT]intelcom[DOT]si> wrote in message news:bm********@enews3.newsguy.com...
dim editmode as boolean (declared in form)

i like to use word "me." because it display members so i don't have to type
a lot :o)

habix

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
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


Nov 20 '05 #7
is it me or dous the ListView1.SelectedItems.Count give 0 even if the first
item is selected?

Dim i As Integer = ListView1.SelectedItems.Count

If i > 0 Then

If booEditMode = True Then

End If
"HABJAN ®iga" <habix[AT]intelcom[DOT]si> wrote in message
news:bm********@enews3.newsguy.com...
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)


Nov 20 '05 #8
Cor
Hi Eric,
Most indexes starts in VB.net at 0. Only the so called
Microsoft.Visual.Basic components are starting mostly at 1. (VB collection,
funtions like find etc).

I hope this helps a little bit?
Cor
Nov 20 '05 #9
When you have item1 selected and you click on other item you get 2 events:

- The first one is triggered when the first item is deselected
(multiselect)
- The second one notifys you the new item is selected
anyways thanks for all the help guys

best re,
habix

"EricJ" <er********@THISomnipack.be> wrote in message
news:3f***********************@reader1.news.skynet .be...
is it me or dous the ListView1.SelectedItems.Count give 0 even if the first item is selected?

Dim i As Integer = ListView1.SelectedItems.Count

If i > 0 Then

If booEditMode = True Then

End If
"HABJAN ®iga" <habix[AT]intelcom[DOT]si> wrote in message
news:bm********@enews3.newsguy.com...
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)



Nov 20 '05 #10
Cor
Hi Habjan,
That is why I told you I use the mouse down
Cor
Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
2
by: Anushya devi | last post by:
Hi All I used listview and tried to update it by using Addrange. When the number of items is less, it works fine.. But I need to update nearly 200,000 items and it hangs. Also i need to add...
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
13
by: Maheshkumar.R | last post by:
hi groups, I have placed an listview control, i want to iterate thru the control and find the clicked event items. listView2.Items.Add(fname.ToString(), i); how i can perform the iteration...
1
by: Jonesgj | last post by:
Hi, First time I am using this control in lieu of a listbox, and I want to be able to get values and row positions back ... I seem to be able to get the first col value back using focusitem, but...
4
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't...
0
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
12
by: Tom Bean | last post by:
I am trying to display a ContextMenuStrip when a user right-clicks on an item in a ListView and have encountered a something that seems strange to me. When the ListView is initially populated,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.