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

        ' 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?

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

This article has been dead for over six months. Start a new discussion instead.