List View Control in VB.

  • Thread starter Thread starter Praveen R
  • Start date Start date
P

Praveen R

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.
 
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
 
or w
selectedindex = -1

Tom Spink said:
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
 
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.
 
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
 
Hi Praveen, it appears like this is VB5/6 code. You may have better luck
posting to a VB5/6 group:

microsoft.public.vb.*

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

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations


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.
 
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.

--------------------
 
Back
Top