473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Selec tIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selec teditems.item(0 ).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.Selec tIndexChanged), 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?",yesno cancel,...)
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
me.listview1.it ems(me.intEditI ndex).selected= true;
end if
else
loadmask(listvi ew1.selectedite ms.item(0))
end if
end if
End Sub

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

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
if booSlave=true then exit sub
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
booSlave=true
me.listview1.it ems(me.intEditI ndex).selected= true;
booSlave=false
end if
else
loadmask(listvi ew1.selectedite ms.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 1870
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.Selec tIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selec teditems.item(0 ).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.Selec tIndexChanged), 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?",yesno cancel,...)
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
me.listview1.it ems(me.intEditI ndex).selected= true;
end if
else
loadmask(listvi ew1.selectedite ms.item(0))
end if
end if
End Sub

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

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
if booSlave=true then exit sub
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
booSlave=true
me.listview1.it ems(me.intEditI ndex).selected= true;
booSlave=false
end if
else
loadmask(listvi ew1.selectedite ms.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.Selec tIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selec teditems.item(0 ).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.Selec tIndexChanged), 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?",yesno cancel,...)
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
me.listview1.it ems(me.intEditI ndex).selected= true;
end if
else
loadmask(listvi ew1.selectedite ms.item(0))
end if
end if
End Sub

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

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
if booSlave=true then exit sub
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion)
if res = msgboxresult.ca ncel then
booSlave=true
me.listview1.it ems(me.intEditI ndex).selected= true;
booSlave=false
end if
else
loadmask(listvi ew1.selectedite ms.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.n l...
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.n l...
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.Selec tedItems.Count give 0 even if the first
item is selected?

Dim i As Integer = ListView1.Selec tedItems.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.Selec tIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true,
intEditIndex = Listview1.selec teditems.item(0 ).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.Selec tIndexChanged), 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?",yesno cancel,...)
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion) if res = msgboxresult.ca ncel then
me.listview1.it ems(me.intEditI ndex).selected= true;
end if
else
loadmask(listvi ew1.selectedite ms.item(0))
end if
end if
End Sub

I understand that when i call
'me.listview1.i tems(me.intEdit Index).selected =true;' i will be notifyed
again on event Listview1.Selec tedIndexChanged so i added another boolean

to
filter out unwanted events (see the booSlave).

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
if booSlave=true then exit sub
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion) if res = msgboxresult.ca ncel then
booSlave=true
me.listview1.it ems(me.intEditI ndex).selected= true;
booSlave=false
end if
else
loadmask(listvi ew1.selectedite ms.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.Visua l.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********@THI Somnipack.be> wrote in message
news:3f******** *************** @reader1.news.s kynet.be...
is it me or dous the ListView1.Selec tedItems.Count give 0 even if the first item is selected?

Dim i As Integer = ListView1.Selec tedItems.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.Selec tIndexChanged - i load the mask for
selected item)
- i go to edit mode of the mask for selected item (i set booEdit=true, intEditIndex = Listview1.selec teditems.item(0 ).index)
- i change some fields on my mask
- then i click on other item10 (i get event
Listview1.Selec tIndexChanged), 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?",yesno cancel,...)
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel + MsgBoxStyle.Que stion) if res = msgboxresult.ca ncel then
me.listview1.it ems(me.intEditI ndex).selected= true;
end if
else
loadmask(listvi ew1.selectedite ms.item(0))
end if
end if
End Sub

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

Dim booSlave as boolean=false
Private Sub ListView1Ch(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Listview1.Selec tedIndexChanged
if booSlave=true then exit sub
If Listview1.selec teditems.count > 0 then
if me.editmode then
Dim res As Microsoft.Visua lBasic.MsgBoxRe sult
res = MsgBox("Save?", MsgBoxStyle.Yes NoCancel +

MsgBoxStyle.Que stion) if res = msgboxresult.ca ncel then
booSlave=true
me.listview1.it ems(me.intEditI ndex).selected= true;
booSlave=false
end if
else
loadmask(listvi ew1.selectedite ms.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

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

Similar topics

1
23676
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 ). If possible, what do I do to activate that 'cell' - thanks. I thought that listView.LabelEdit = true; would enable me to navigate into the...
2
4714
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 images to listview also(This is to list all the items in my inbox, and want to give the user the feel of outlook). Since it hangs for even 1000 items...
0
5405
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 board. I have a form that contains a ListView and a GroupBox control. The GroupBox control itself contains several TextBox Controls. I have...
13
3739
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 to find the item clicked...? and its item. thankz-- Mähésh Kumär. R
1
1166
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 what if I want values from other cols?? I also may want to find the position of the row selected. In listbox I use the selectindex, how would i...
4
10779
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 not want to display this menu if a node selected on the listview but user right click over the empty space of the panel that contain the listview. ...
0
1882
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 form every thing works fine: checking items by code as well as checking with mouse: Using the CheckdItems Property is confused too.
2
6816
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 form every thing works fine: checking items by code
12
4002
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, no items are selected. When the first item is selected by clicking either the left or right button, the SelectedIndexChanged event fires but not the...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.