请帮助表格VS2015社区版之间传递价值 [英] Help with passed in value between forms VS2015 community edition please

查看:58
本文介绍了请帮助表格VS2015社区版之间传递价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Visual Studio 2015社区版,发现我无法再使用我在VB2010 Express中使用的简单代码。



我正在尝试使用简单客户/订单示例的改编版本,该示例在网络上的许多教程中有所描述。如果我使用示例,其中customer表(在我的情况下是一个帐户列表)显示为详细信息或单个文本框,并且订单(在我的情况下银行详细信息)显示在同一表单上的DataGridView中,它完美地工作。如果我尝试在两个表单上使用相同的数据集,它将在2015年无法正常工作。第一个表单显示帐户数据,第二个表单应仅显示所选银行帐户的详细信息我使用相同的代码VB2010 Express。我知道从第一种形式到第二种形式的传入值是正确的。为了证明我已经传递了正确的值,我在第二个表单上放置了一个标签来显示该值。这工作正常。该值跟踪帐户表单上的所选记录。



我的问题是,第二个表单上的datagridview不显示所选客户的银行详细信息无法弄清楚为什么它会以这种方式表现出来。它显示所有帐户,好像我从数据集中选择了错误的帐户表,但我知道我没有其他单一表单示例不起作用。



我认为问题在于第二批代码中的AccountID第3行,但我不知道如何纠正这个问题。因为它是一个整数,我甚至在那里放了一个有效的LoAID号,但是也被忽略了。



有人可以给我VS2015的正确语法吗? br />


我尝试过:



I have just started using Visual Studio 2015 Community Edition and found that I can no longer use simple code that I used in VB2010 Express.

I am trying to use an adapted version of the simple Customers/Orders example which is described in many tutorials on the web. If I use the example where the customer table (in my case a list of accounts) is displayed as details or individual textboxes and the orders (in my case bank details) are displayed in a DataGridView on the same form, it works perfectly. If I try to use the same dataset on two forms, it will not work properly in 2015. The first form displays the Accounts data and the second form should display only the details for the selected bank account I am using the same code that worked in VB2010 Express. I know that the passed in value from the first form to the second form is correct. To prove that I have passed the correct value, I have placed a label on the second form to display the value. That works correctly. The value tracks with the selected record on the accounts form.

My problem is that the datagridview on the second form does not display the bank details for the selected customer and I cannot figure out why it behaves in this way. It displays all of the accounts as if I had chosen the wrong accounts table from the dataset but I know that I have not otherwise the single form example would not work.

I think the problem lies in line3 with "AccountID" in the second batch of code but I do not know how to rectify the problem. As it is an integer, I have even put a valid LoAID number in there but that too is ignored.

Can somebody please give me the correct syntax for VS2015?

What I have tried:

'Passed in value is LoAID from Form2  
02.    Public Sub New(ByVal LoAID As Integer)  
03.  
04.        ' This call is required by the designer.  
05.        InitializeComponent()  
06.  
07.        ' Add any initialization after the InitializeComponent() call.  
08.  
09.        'LoAID is the Primary key value from Form2's data table  
10.        Me.AccountID = LoAID 'For test purposes display passed in value from Form2.  Label1 displays the correct value  
11.        Label1.Text = AccountID  







Private Sub Form10_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
02.        'TODO: This line of code loads data into the 'AccountBankDataSet.Account' table. You can move, or remove it, as needed.  
03.        Me.AccountTableAdapter.FillByLoAID(Me.AccountBankDataSet.Account, AccountID)  
04.        'TODO: This line of code loads data into the 'AccountBankDataSet.Bank' table. You can move, or remove it, as needed.  
05.        Me.BankTableAdapter.Fill(Me.AccountBankDataSet.Bank)  
06.  
07.        Me.MdiParent = MDIParent1  
08.  
09.        Me.Location = New Point(50, 50)  
10.  
11.    End Sub  

推荐答案

试试这个:

Try this:
Label1.Text = AccountID.ToString()


我已经解决了这个问题。请参阅此Microsoft链接:



在表单之间传递数据 [ ^ ]
I have solved the problem. See this Microsoft link:

Pass data between forms[^]


这篇关于请帮助表格VS2015社区版之间传递价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆