Avatar of cherosoullis
cherosoullis asked on

MDI container produce an error

Hello,
I have a problem with an application I made. I made my application in VB 2005 and it's working just fine.
In order to make it look better I decided to make a master form and make it mdi container where all the other form will be shown.
I load my first form from the MenuStrip and all the buttons are just fine. From this first form I try to load another form which will produce me a report in crystal report and I need:
1) To make the second form MDI child
2) To be aple to retreive the selected row from datagrid of the first form.
This problem was created when I make the first form an MDI container and I don't know how to fix this. Bellow you will find the code that is retreiving the selected row from the first form.
Thanks.
Private Sub PrintSelectedUserID()
 
        Dim userID As Integer
 
        If frmMain.DataGridView.SelectedRows.Count = 0 And frmMain.DataGridView.RowCount = 0 And frmMain.DataGridView.SelectedCells.Count = 0 Then
            MessageBox.Show("Update not allowed as no row/cell is selected!", ".NET Remoting Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End If
 
        'If cell only is selected, use this to find the UserID
        If frmMain.DataGridView.SelectedRows.Count = 0 And frmMain.DataGridView.SelectedCells.Count > 0 Then
            userID = CType(frmMain.DataGridView.Rows(frmMain.DataGridView.SelectedCells(0).RowIndex).Cells("UserID").Value, Integer)
            'If full row is selected, use this to find the UserID
        ElseIf frmMain.DataGridView.SelectedRows.Count > 0 And frmMain.DataGridView.SelectedCells.Count > 0 Then
            userID = CType(frmMain.DataGridView.Rows(frmMain.DataGridView.SelectedCells(0).RowIndex).Cells("UserID").Value, Integer)
        End If

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
Jorge Paulino

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jorge Paulino

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck