我有一个包含一些菜单项的菜单列表,这些菜单项打开一个接受参数的表格。目前,当打开表单时,它将创建另一个表单,而不是专注于已经打开的表单。
我看过很多C#示例,但是很难转换它们。
我已经尝试过此代码,但是我认为它不起作用,因为尽管菜单窗体是一个mdiContainer窗体,但它打开的窗体不是孩子。我已将其显示为我要查找的内容,即特定的CLASS形式的表单。
For Each child In Me.MdiChildren
If TypeOf child Is frmCustomerPurchaseOrders Then
child.WindowState = FormWindowState.Normal
child.Focus()
Exit Sub
End If
Next
Dim myForm As New frmCustomerPurchaseOrders("NotFullyInvoiced")
myForm.Show()
我看过My.Application.OpenForms,它确实会拾取表单文本,但是当打开时表单文本发生变化时,很难按表单名称进行匹配。有没有一种方法可以检查特定的Class类表单是否已经打开?
For Each f As Form In My.Application.OpenForms
MessageBox.Show(f.Text)
Next
但是,如果我在执行此操作时走错了路,请告诉我!非常感谢
答案 0 :(得分:2)
您可以使用OpenForms进行完全相同的操作,就像您的示例代码中使用MdiChildren一样。只需在循环中检查每个表单// Summary:
// Partitioner: `random` - random distribution, `consistent` - CRC32 hash of key
// (Empty and NULL keys are mapped to single partition), `consistent_random` - CRC32
// hash of key (Empty and NULL keys are randomly partitioned), `murmur2` - Java
// Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
// `murmur2_random` - Java Producer compatible Murmur2 hash of key (NULL keys are
// randomly partitioned. This is functionally equivalent to the default partitioner
// in the Java Producer.). default: consistent_random importance: high
的类型:
f