473,395 Members | 1,941 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,395 software developers and data experts.

List View Control in VB.

Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no
information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on
a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.
Nov 20 '05 #1
5 2273
Hi, you can check to see if the selected item is valid:

' ///
If MyListView.SelectedItem Is Nothing Then
' There is no selected item
Else
' There is a selected item
End If
' ///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Praveen R" <pr*****@me.sage.com> wrote in message
news:05****************************@phx.gbl...
Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no
information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on
a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.

Nov 20 '05 #2
or w
selectedindex = -1

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
Hi, you can check to see if the selected item is valid:

' ///
If MyListView.SelectedItem Is Nothing Then
' There is no selected item
Else
' There is a selected item
End If
' ///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Praveen R" <pr*****@me.sage.com> wrote in message
news:05****************************@phx.gbl...
Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no
information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on
a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.


Nov 20 '05 #3
Hi Tom,

Thanks for your email. I tried what you have suggested. If
the listview is totally blank, then this works. But if the
listview has atleast one row of data, then the condition
listview.selecteditem is nothing is never true. What i
need to trap is, when the mouse click happens on a blank
row of the listview.

Please do revert.

Many Thanks,
Praveen.
-----Original Message-----
Hi, you can check to see if the selected item is valid:

' ///
If MyListView.SelectedItem Is Nothing Then
' There is no selected item
Else
' There is a selected item
End If
' ///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Praveen R" <pr*****@me.sage.com> wrote in message
news:05****************************@phx.gbl...
Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.

.

Nov 20 '05 #4
Hi EricJ,

The ListView control does not have a SelectedIndex property, nor does it
have a SelectedItem property, so the poster must have posted VB5/6 code.

So, in .NET:

If MyListView.SelectedItems.Count = 0 Then
' There are no selected items
Else
' There are selected items
End If

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"EricJ" <er********@THISomnipack.be> wrote in message
news:3f***********************@reader1.news.skynet .be...
or w
selectedindex = -1

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
Hi, you can check to see if the selected item is valid:

' ///
If MyListView.SelectedItem Is Nothing Then
' There is no selected item
Else
' There is a selected item
End If
' ///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Praveen R" <pr*****@me.sage.com> wrote in message
news:05****************************@phx.gbl...
Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no
information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on
a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.



Nov 20 '05 #5
Hi Praveen,

If you are using VB6, I think you may try to handle the ItemClick event,
which is differenct from the Click event.

If you are using VB.NET, You may try to derive a new ListView and override
the WinProc function to achieve your aim.

If you have related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Praveen R" <pr*****@me.sage.com>
Sender: "Praveen R" <pr*****@me.sage.com>
Subject: List View Control in VB.
Date: Tue, 7 Oct 2003 04:18:42 -0700
Lines: 18
Message-ID: <05****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOMxMOyjXI0TVztSuGNAsUk6ldEgw==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:144491
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi !

I am using a List view control to populate data onto. On
the click event of the list view control, i need to find
out whether the area clicked has any information of has no
information. I basically need to either decide to add a
new record or edit the existing record depending on
whether data is available or not on the row where the
mouse click was performed.

I have tried using listViewControl.SelectedItem.Text .
This always returns the text of the selected item, there
indicating that there is a record. But if the click is on
a blank row, an empty text is not returned.

Will be glad if anyone can suggest a way around this.

Many Thanks.


Nov 20 '05 #6

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

Similar topics

11
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
3
by: idletask | last post by:
I have an application that has many windows. One window is used for order processing. I would like this window to display the other users who are also performing order processing (the idea is to...
1
by: jollyguy77 | last post by:
Hi, I have just started to learn in .net. I want to show a list of filename along with the corresponding image (like pdf image for pdf files etc..). i will be getting the list of files from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.