本文介绍了识别TextChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下例程:



I have the following routine :

Private Sub FormChanged(ByVal sender As Object, ByVal e As EventArgs) Handles _
    cbo_Contact.TextChanged, _
    cbo_Currency.TextChanged, _
    cbo_Delivery_Address.TextChanged, _
    cbo_Delivery_From.TextChanged, _
    cbo_Delivery_To.TextChanged, _
    cbo_General.TextChanged, _
    cbo_Payment_Terms.TextChanged, _
    cbo_Project_Number.TextChanged, _
    cbo_Supplier.TextChanged, _
    cbo_Type.TextChanged, _
    dtp_Delivery_Date_From.ValueChanged, _
    dtp_Delivery_Date_To.ValueChanged, _
    mxt_Settlement_Discount.TextChanged, _
    cbo_Description.TextChanged, _
    mxt_Qty.TextChanged, _
    cbo_Unit.TextChanged, _
    txt_Price.TextChanged, _
    txt_Discount.TextChanged, _
    cbo_Incoterm.TextChanged, _
    cbo_Inco_Named_Place.TextChanged, _
    cbo_Inco_Place.TextChanged, _
    chk_No_Vat.CheckedChanged, _
    rxt_Notes.TextChanged

    theFormChanged = True

End Sub





显然,如果任何列表组合框,文本框等发生变化,那么我知道表单上的内容已经发生变化并且应该发生保存。



在上述例程中,有什么方法可以确定哪一个改变了?



类似于:



如果cbo_Supplier.TextChanged = True然后DoSomething ???



Obviously if any of the list comboboxes, textboxes etc changes then I know that something on the form has changed and a Save should occur.

Is there any way, within the above routine, that I can identify which one changed?

Something like :

if cbo_Supplier.TextChanged = True then DoSomething ???

推荐答案

If TypeOf sender Is ComboBox Then
          Dim MyCombo As ComboBox = CType(sender, ComboBox)
          MsgBox(MyCombo.Name)
      End If



这篇关于识别TextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 10:41