Hey All!

I'm working on a project at the moment, where there are a variety of sections. Each section has its own window and WPF controls. Each window has a tab control, with tabs to 'View', 'Add', 'Edit' and 'Delete' records. The 'View' tab has a ListView which is populated with records from a database (using LINQ to SQL).

From the 'View' tab, users must have the abilitye to select a record from the ListView to edit or delete. By selecting the record and clicking on the relevant button ('Edit' or 'Delete') the relevant tab will be selected and the controls in that tab will be populated with the details of the selected record.

I know how to change the tabs by changing the TabControl selected index property, but I'm not sure how to pass the information across to the relevant tab item. In VB I used a procedure in the first form to pass the variables to the other windows form:

Using f As New FrmDetails(action)
                ' display the form
                f.ShowDialog()
            End Using

And then the following procedure would be in the code of the form receiving the information

' recieve passed through variable
    Sub New(ByVal var As String)
        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        action = var ' var is the variable passed from the previous form
    End Sub

I assume something similar could be done in C# but I'm not sure how to proceed because I don't see how this would work with the TabControl.

The only way I could see to do it would be to have a gloabl variable to store the object that must be passed, with a default value of null and then each time the tabControl index is changed I could fill the form based on this variable but that doesn't seem like a very efficient method.

Any ideas?
Regards
Laura

P.S. Sorry about the VB code snippets in C# syntax. I wasn't sure how to change it to VB.Net. If anyone can tell me, I'd appreciate that as well :D

Thanks for the information, I appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.