PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 [RESOLVED] ListView as Detail - database id-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] ListView as Detail - database id

  1. #1

    Thread Starter
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Resolved [RESOLVED] ListView as Detail - database id


    I have seen listview controls before that do not show any type of ID. (ie: Items in an order).
    So when I delete this row, how does it know which row to delete in my database? There could be many rows with the same exact data but each belonging to a different order. Would there be a hidden column with the record ID in it?
    If it is a hidden column, how would I go about this?

    I've used this method for returning id's for ComboBox's and Listbox's:
    http://www.vb-helper.com/howto_net_listbox_class.html

    Thanks for any help in advance.
    VB 6 / VB.NET 2003, 2005 / Crystal Reports 9-12

  2. #2

    Thread Starter
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: ListView as Detail - database id

    Thanks to an external source, I finally found out about the listview "TAG".

    vb Code:
    1. Dim lv1 As ListViewItem = ListView1.Items.Add("!")
    2.  lv1.SubItems.Add("A")
    3.  lv1.Tag = 195
    4.  
    5.  ListView1.Items.Add("!")
    6.  lv1.SubItems.Add("B")
    7.  lv1.Tag = 102

    Then:
    vb Code:
    1. Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
    2.         Dim lvi As ListViewItem = ListView1.SelectedItems(0)
    3.         If lvi IsNot Nothing Then Debug.WriteLine(lvi.Tag)
    4.     End Sub

    I am working out a bug on the "SelectedIndex" Command. If I add a Try/Catch it works ok each time. Otherwise I get an error of
    "InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index"
    after the first time which works ok.
    VB 6 / VB.NET 2003, 2005 / Crystal Reports 9-12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width