English 中文(简体)
表格没有定义VB。 NET
原标题:Form is not defined VB.NET

I m 试图将一个表格物体储存成一个变数,但不能成功:

该法典没有工作:

Dim invoice_form As billing_new_invoice

     Get last remote Row
    Dim last_row As Integer = CType(main.ActiveMdiChild, invoice_form).invoiceitems_new_invoice.Rows.Count - 1

    Dim count_row As Integer = CType(main.ActiveMdiChild, invoice_form).invoiceitems_new_invoice.Rows.Count()

该法典规定:

Dim invoice_form As billing_new_invoice

     Get last remote Row
    Dim last_row As Integer = CType(main.ActiveMdiChild, billing_new_invoice).invoiceitems_new_invoice.Rows.Count - 1

    Dim count_row As Integer = CType(main.ActiveMdiChild, billing_new_invoice).invoiceitems_new_invoice.Rows.Count()

“Error”/

I need to store the form instance in the variable (invoice_form), that could be used in multiple lines of code, but it says (Type invoice_form is not defined.) Anyone have idea to solve this ?

最佳回答

不清楚问题是什么。 我认为,你正在寻找这样的东西:

If TypeOf Me.ActiveMdiChild Is billing_new_invoice Then
  Dim invoice_Form As billing_new_invoice = Me.ActiveMdiChild

  Dim last_row As Integer = invoice_form.invoiceitems_new_invoice.Rows.Count - 1
  Dim count_row As Integer = invoice_form.invoiceitems_new_invoice.Rows.Count()

  // etc

End If

现行法典的问题在于,它试图把它变成一个变量,而不是一种类型。 <代码>invoice_form是一个变量,billing_new_invoice<>code>为一类。

问题回答

CType用于类型转换,而不是变式转让。 你们想要做的是先把变量分配给形式,然后使用这一变量:

Dim invoice_form As billing_new_invoice = CType(main.ActiveMdiChild, billing_new_invoice)
Dim last_row As Integer = invoice_form.invoiceitems_new_invoice.Rows.Count - 1




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.