Click here to Skip to main content
15,902,275 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: TcpListener problem Pin
Dave Kreskowiak30-Jan-10 6:30
mveDave Kreskowiak30-Jan-10 6:30 
GeneralRe: TcpListener problem Pin
AliAmjad31-Jan-10 1:49
AliAmjad31-Jan-10 1:49 
QuestionBindingSource Pin
wikus7029-Jan-10 1:00
wikus7029-Jan-10 1:00 
AnswerRe: BindingSource Pin
Wayne Gaylard29-Jan-10 2:13
professionalWayne Gaylard29-Jan-10 2:13 
GeneralRe: BindingSource Pin
wikus7031-Jan-10 19:25
wikus7031-Jan-10 19:25 
GeneralRe: BindingSource Pin
Wayne Gaylard1-Feb-10 0:54
professionalWayne Gaylard1-Feb-10 0:54 
GeneralRe: BindingSource Pin
wikus701-Feb-10 2:47
wikus701-Feb-10 2:47 
GeneralRe: BindingSource Pin
Wayne Gaylard1-Feb-10 21:16
professionalWayne Gaylard1-Feb-10 21:16 
As far as I can tell, you basically want form2 to display the information of a particular PC, depending on the row clicked by the user in the DataGridView in form1. Have a look at the code below for form1 and form2 as I would implement this.

    Public Class PC

        Private intID As Integer
        Private strName As String

        Public Sub New()

        End Sub

        Public Sub New(ByVal PCID As Integer)

            ID = PCID
            Name = "PC " & PCID

        End Sub

        Public Property Name() As String
            Get
                Return strName
            End Get
            Set(ByVal value As String)
                strName = value
            End Set
        End Property

        Public Property ID() As Integer
            Get
                Return intID
            End Get
            Set(ByVal value As Integer)
                intID = value
            End Set
        End Property

    End Class

    Public Class Form1

    Private lstPC As New List(Of PC)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        'Create some simple PC's for example purposes
        For i As Integer = 1 To 5
            Dim newPC As New PC
            newPC.ID = i
            newPC.Name = "PC " & i
            lstPC.Add(newPC)
        Next
        DataGridView1.DataSource = lstPC

    End Sub

    Private Sub DataGridView1_CellMouseClick(ByVal sender As Object, ByVal e As  System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick

        Dim newForm2 As New Form2(lstPC(e.RowIndex))
        newForm2.Show()

    End Sub

End Class

Public Class Form2

    Private pcCurrent As Form1.PC

    Public Sub New(ByVal newPC As Form1.PC)

        InitializeComponent()
        pcCurrent = newPC

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ListView1.Items.Add(pcCurrent.Name)

    End Sub

End Class


To run this, you need to have Form1 with a DataGridView named DataGridView1, and a second form Form2 with a ListView (ListView1). For this example I created a simple PC class, and just pass the particular PC object to form2 via form2's constructor. There are various ways of doing this, i.e creating a public property in form2 that returns a PC object, and then when declaring your new form2 you set the property to the specific PC object your user wanted. Hope this helps.
QuestionHow to access an unknown file format? Pin
Sonhospa28-Jan-10 23:24
Sonhospa28-Jan-10 23:24 
AnswerRe: How to access an unknown file format? Pin
Dave Kreskowiak29-Jan-10 2:23
mveDave Kreskowiak29-Jan-10 2:23 
GeneralRe: How to access an unknown file format? Pin
Sonhospa29-Jan-10 5:30
Sonhospa29-Jan-10 5:30 
GeneralRe: How to access an unknown file format? Pin
Richard MacCutchan29-Jan-10 6:41
mveRichard MacCutchan29-Jan-10 6:41 
QuestionZedGraph question Pin
TheComputerMan28-Jan-10 3:56
TheComputerMan28-Jan-10 3:56 
QuestionReferences in Class Library Pin
Jay Royall27-Jan-10 23:52
Jay Royall27-Jan-10 23:52 
AnswerRe: References in Class Library Pin
Gideon Engelberth28-Jan-10 2:51
Gideon Engelberth28-Jan-10 2:51 
GeneralRe: References in Class Library Pin
Jay Royall28-Jan-10 4:49
Jay Royall28-Jan-10 4:49 
QuestionDelete record using ADODC in vb6 Pin
offroaderdan27-Jan-10 23:48
offroaderdan27-Jan-10 23:48 
AnswerRe: Delete record using ADODC in vb6 Pin
Estys28-Jan-10 0:20
Estys28-Jan-10 0:20 
GeneralRe: Delete record using ADODC in vb6 Pin
offroaderdan28-Jan-10 0:50
offroaderdan28-Jan-10 0:50 
GeneralRe: Delete record using ADODC in vb6 Pin
Estys28-Jan-10 1:24
Estys28-Jan-10 1:24 
QuestionMDX Change array to list Pin
led12327-Jan-10 3:44
led12327-Jan-10 3:44 
QuestionMD5 checksum problem Pin
Gagan.2027-Jan-10 2:18
Gagan.2027-Jan-10 2:18 
AnswerRe: MD5 checksum problem Pin
Covean27-Jan-10 2:37
Covean27-Jan-10 2:37 
GeneralRe: MD5 checksum problem Pin
Gagan.2027-Jan-10 2:48
Gagan.2027-Jan-10 2:48 
GeneralRe: MD5 checksum problem Pin
DaveAuld27-Jan-10 3:06
professionalDaveAuld27-Jan-10 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.