Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Those code are from frmBillingPatient..

my problem is when I select a row in patientListView i cant put it into the lblTry in frmBillingManagement, its not working. But its working with the frmMain.

Note:
frmBillingManagement is a user control
frmMain is a form

thanks!

What I have tried:

Public Sub patientListView_MouseClick(sender As Object, e As MouseEventArgs) Handles patientListView.MouseClick
patientID = patientListView.FocusedItem.SubItems(1).Text
frmMain.Label1.Text = patientID.ToString
frmBillingManagement.lblTry.Text = patientID.ToString
frmBillingManagement.Refresh()
frmBillingManagement.lblTry.Refresh()
Me.Close()
End Sub
Posted
Updated 27-Feb-17 8:23am
Comments
[no name] 27-Feb-17 8:16am    
Making your controls public is a terrible idea.
Krizzia Mostaza 27-Feb-17 8:19am    
i just tried that cause i thought it was the prob . but i changed it to private again. can u help me?
[no name] 27-Feb-17 9:01am    
Look up "properties in VB.NET"

1 solution

VB.NET provides a default instance of each form in a Windows Forms application, primarily for backwards-compatibility with VB6.

Default Object Instances Provided by My.Forms and My.WebServices (Visual Basic)[^]
My.Forms Object[^]
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET[^]

So, when you reference frmMain.something, you're actually referring to the default instance of the class frmMain.

The same is not done for user controls. An instance of a user control without a containing form would serve no purpose. And since the control could be used multiple times on multiple different forms, there would be no sensible way to pick a single "default" instance.

Instead, the user control will be exposed as (one or more) members on the containing form. Each instance of the control will have an ID assigned, which you can change using the design view.

So, if your control instance is on the current form, with an ID of billingManagement1, you'd use:
VB.NET
billingManagement1.lblTry.Text = patientID.ToString()

If it was on frmMain:
VB.NET
frmMain.billingManagement1.lblTry.Text = patientID.ToString()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900