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
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo