Text_Change事件未提升

时间:2015-12-22 21:08:28

标签: vb.net visual-studio-2013 label textchanged

我有以下代码:

private sub xtoy()
    lbl_packed_as.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DatasetProduct, "tbl_products.packed_fresh_or_frozen"))
end sub

和此:

Private Sub lbl_packed_as_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_packed_as.TextChanged
    Select Case lbl_packed_as.Text
        Case "FR"
            rdb_fresh.Checked = True
        Case "FZ"
            rdb_frozen.Checked = True
        Case "NA"
            rdb_na.Checked = True
    End Select
End Sub

此时标签为lbl_packed_as.Visible=false,因此我无法达到上述方法。如果我设置lbl_packed_as.Visible=True,则上述方法正常。我不想在屏幕上显示lbl_packed_as标签。

任何帮助?

1 个答案:

答案 0 :(得分:1)

正如我在评论中所说,您可以将Label的位置更改为不在表单可视区域内的点。

我建议您使用设计师窗口将标签放在您通过设计师查看表单时可以看到的位置。然后,在代码中,将其移动到其他位置。您可以使用此单行在Form_Load事件中执行此操作。

' Move the control to a position before the top and left border
' In this way it is not visible to the end user but still retains 
' its visible property to allow databindings to function
lbl_packed_as.Location = new Point(-1000, -1000)