BindingManagerBase.CurrentChanged Kejadian
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Terjadi ketika item yang saat ini terikat berubah.
public:
event EventHandler ^ CurrentChanged;
public event EventHandler CurrentChanged;
member this.CurrentChanged : EventHandler
Public Custom Event CurrentChanged As EventHandler
Jenis Acara
Contoh
Contoh kode berikut mencetak nilai Current objek dalam peristiwa BindingManagerBaseCurrentChanged . Contoh mengasumsikan sumber data berisi DataTable yang DataColumn bernama CustName
.
void Current_Changed( Object^ sender, EventArgs^ /*e*/ )
{
BindingManagerBase^ bm = dynamic_cast<BindingManagerBase^>(sender);
/* Check the type of the Current object. If it is not a
DataRowView, exit the method. */
if ( bm->Current->GetType() != DataRowView::typeid )
return;
// Otherwise, print the value of the column named "CustName".
DataRowView^ drv = dynamic_cast<DataRowView^>(bm->Current);
Console::Write( "CurrentChanged): " );
Console::Write( drv[ "CustName" ] );
Console::WriteLine();
}
private void Current_Changed(object sender, EventArgs e)
{
BindingManagerBase bm = (BindingManagerBase) sender;
/* Check the type of the Current object. If it is not a
DataRowView, exit the method. */
if(bm.Current.GetType() != typeof(DataRowView)) return;
// Otherwise, print the value of the column named "CustName".
DataRowView drv = (DataRowView) bm.Current;
Console.Write("CurrentChanged): ");
Console.Write(drv["CustName"]);
Console.WriteLine();
}
Private Sub Current_Changed(sender As Object, e As EventArgs)
Dim bm As BindingManagerBase = CType(sender, BindingManagerBase)
' Check the type of the Current object. If it is not a
' DataRowView, exit the method.
If bm.Current.GetType() IsNot GetType(DataRowView) Then
Return
End If
' Otherwise, print the value of the column named "CustName".
Dim drv As DataRowView = CType(bm.Current, DataRowView)
Console.Write("CurrentChanged): ")
Console.Write(drv("CustName"))
Console.WriteLine()
End Sub
Keterangan
Peristiwa CurrentChanged dimunculkan setiap kali Current properti berubah atau CurrentItemChanged peristiwa terjadi.
Untuk informasi selengkapnya tentang menangani peristiwa, lihat Menangani dan Menaikkan Peristiwa.