We help IT Professionals succeed at work.
Get Started

MDI container produce an error

cherosoullis
cherosoullis asked
on
182 Views
Last Modified: 2012-05-06
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

Comment
Watch Question
IT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE