Klasa DataRepeaterItemEventArgs
Dostarcza dane dla DrawItem zdarzenia.
Hierarchia dziedziczenia
Object
EventArgs
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
Przestrzeń nazw: Microsoft.VisualBasic.PowerPacks
Zestaw: Microsoft.VisualBasic.PowerPacks.Vs (w Microsoft.VisualBasic.PowerPacks.Vs.dll)
Składnia
'Deklaracja
Public Class DataRepeaterItemEventArgs _
Inherits EventArgs
public class DataRepeaterItemEventArgs : EventArgs
public ref class DataRepeaterItemEventArgs : public EventArgs
type DataRepeaterItemEventArgs =
class
inherit EventArgs
end
public class DataRepeaterItemEventArgs extends EventArgs
Typ DataRepeaterItemEventArgs uwidacznia następujące elementy członkowskie.
Konstruktorzy
Nazwa | Opis | |
---|---|---|
![]() |
DataRepeaterItemEventArgs | Inicjuje nowe wystąpienie DataRepeaterItemEventArgs klasy. |
Początek
Właściwości
Nazwa | Opis | |
---|---|---|
![]() |
DataRepeaterItem | Pobiera DataRepeaterItem , które dostarcza dane dla DrawItem zdarzenia DataRepeater sterowania |
Początek
Metody
Nazwa | Opis | |
---|---|---|
![]() |
Equals | Determines whether the specified object is equal to the current object. (Odziedziczone z Object). |
![]() |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Odziedziczone z Object). |
![]() |
GetHashCode | Serves as the default hash function. (Odziedziczone z Object). |
![]() |
GetType | Gets the Type of the current instance. (Odziedziczone z Object). |
![]() |
MemberwiseClone | Creates a shallow copy of the current Object. (Odziedziczone z Object). |
![]() |
ToString | Returns a string that represents the current object. (Odziedziczone z Object). |
Początek
Uwagi
Użyj DrawItem zdarzenie, aby zmienić wygląd DataRepeaterItem obiektów, jak są one przewijane do widoku.
W czasie wykonywania właściwości dotyczące wyglądu można ustawić na podstawie warunków.Na przykład w aplikacji planowania, można zmienić kolor tła elementu, aby ostrzec użytkowników, gdy element jest zadłużone.Jeśli ustawisz właściwość w instrukcji warunkowej takich jak If…Then, należy użyć Else klauzuli, aby określić wygląd, gdy warunek nie jest spełniony.
Przykłady
Poniższy przykład demonstruje, jak używać DrawItem obsługi zdarzeń, aby wprowadzić zmiany, gdy element jest przewijane do widoku.W tym przykładzie założono, że DataRepeater formantu, który jest powiązany z tabelą Produkty w bazie danych Northwind.
Private Sub DataRepeater1_DrawItem(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
) Handles DataRepeater1.DrawItem
' Alternate the back color.
If (e.DataRepeaterItem.ItemIndex Mod 2) <> 0 Then
' Apply the secondary back color.
e.DataRepeaterItem.BackColor = Color.AliceBlue
Else
' Apply the default back color.
e.DataRepeaterItem.BackColor = Color.White
End If
' Change the color of out-of-stock items to red.
If e.DataRepeaterItem.Controls(
UnitsInStockTextBox.Name).Text < 1 Then
e.DataRepeaterItem.Controls(UnitsInStockTextBox.Name).
BackColor = Color.Red
Else
e.DataRepeaterItem.Controls(UnitsInStockTextBox.Name).
BackColor = Color.White
End If
End Sub
private void dataRepeater1_DrawItem(object sender,
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
// Alternate the back color.
if ((e.DataRepeaterItem.ItemIndex % 2) != 0)
// Apply the secondary back color.
{
e.DataRepeaterItem.BackColor = Color.AliceBlue;
}
else
{
// Apply the default back color.
e.DataRepeaterItem.BackColor = Color.White;
}
// Change the color of out-of-stock items to red.
if (e.DataRepeaterItem.Controls["unitsInStockTextBox"].Text == "0")
{
e.DataRepeaterItem.Controls["unitsInStockTextBox"].BackColor = Color.Red;
}
else
{
e.DataRepeaterItem.Controls["unitsInStockTextBox"].BackColor = Color.White;
}
}
Bezpieczeństwo wątku
Wszystkie publiczne static (Shared w języku Visual Basic) elementy członkowskie tego typu są bezpieczne dla wątków. Wystąpienia elementów członkowskich nie dają gwarancji bezpieczeństwa wątków.
Zobacz też
Informacje
Przestrzeń nazw Microsoft.VisualBasic.PowerPacks
Inne zasoby
Wprowadzenie do formantu DataRepeater (Visual Studio)
Porady: zmienianie wyglądu formantu DataRepeater (Visual Studio)