Results 1 to 9 of 9

Thread: LISTVIEW - Form 2 form help :(

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55

    LISTVIEW - Form 2 form help :(

    VB Code:
    1. Dim back As frmmain
    2.  
    3.     Dim lstItems As New ListViewItem
    4.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.  
    6.  
    7.         lstItems = ListView1.Items.Add(nam1)
    8.         lstItems.SubItems.Add(Mid(mem1, 1, 4))
    9.         lstItems.SubItems.Add(nuscheck)
    10.         lstItems.SubItems.Add("£" & tot1)
    11.  
    12.  
    13.  
    14.     End Sub
    15.  
    16.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    17.         mystore = ListView1.Text
    18.         TextBox1.Text = lstItems.Text
    19.     End Sub
    20. End Class

    Hi i need to get this working asap:?/

    i am using a listview and on form2 when data is added it will add itself to form3, but the button on form3 to go back will go back, but when i add new data it will not add to listview with current data:/ how can i get around htis...

    my code is above

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    n e 1

    Reworded:

    question -

    hi i have 2 forms in which the data needs to be transferred from, on form 2 i would like to carry over the name and total aswell as membership number to the listview situated on form3

    membership number = mem1
    name = nam1
    and total = tot1

    well when the proceed button is pressed on form2 it will copy the values (nam1, tot1 and mem1) to form3 and place it in its listview (on form3) and then i also want a back button to form2 so i can reenter other peoples name and when proceed is clicked again it will add it to the listview under the previous entry :/

    if any one understands lol

    cheers
    Last edited by Ezpz; Jan 9th, 2004 at 04:26 PM.

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Can't you just refer to the other form like in VB6? Read the listview items out of one form (form2.lvMembership. etc) to set the items in the listview on form 3.

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    can u set me out an example a short one :/ please as i am a newbie

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Something like this in form3's code:
    VB Code:
    1. Dim item As New ListViewItem(form2.listview1.item(1))
    2.             ListView1.Items.Add(item)
    I'm new to vb.net, more used to listviews in VB6, so that may be off some, but that's the idea. If form3 needed a value in a textbox on form2, say, you could do: strMyString = form2.txtMyTxtbox.text

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    nope dint work thank u anyway any other ideas

  7. #7
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Well, check out the actual code for adding items and subitems to a listview in vb.net, I may have been off there, as I wrote above. You also need to have the listview set to the proper style for columns to work.
    Maybe you can't reference another form in .net, but that seems a backward step.
    Maybe you could declare the listviews in a code module (class module in .net?) using code, then reference them from anywhere in the project, i.e. a global declaration.
    This would be a trivial problem in VB6, and maybe is in .Net, but don't know enough .Net to tell you for sure.

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    nope n e other offers of suggestion

  9. #9
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Originally posted by salvelinus
    Can't you just refer to the other form like in VB6? Read the listview items out of one form (form2.lvMembership. etc) to set the items in the listview on form 3.
    VB6 is nothing like VB.Net, it has the same syntax (names of commands) but other then that its very different.
    I VB6 you can call another form simply by saying

    Form3.WhatEver

    In VB.Net you have to ask the specific instance. You must have a reference to this instance. Ive included a small example of this, with 2 different ways of doing it.
    Id suggest looking up how an OOP language works if you are new to .Net, its one of the most important aspects, there are many example about.
    Attached Files Attached Files
    Last edited by Grimfort; Jan 21st, 2004 at 12:31 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width