DataRepeaterItemEventArgs 類別
提供 DrawItem 事件的資料。
繼承階層架構
Object
EventArgs
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
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
DataRepeaterItemEventArgs 類型會公開下列成員。
建構函式
名稱 | 描述 | |
---|---|---|
DataRepeaterItemEventArgs | 初始化 DataRepeaterItemEventArgs 類別的新執行個體。 |
回頁首
屬性
名稱 | 描述 | |
---|---|---|
DataRepeaterItem | 取得 DataRepeaterItem,這個物件提供 DataRepeater 控制項的 DrawItem 事件資料。 |
回頁首
方法
名稱 | 描述 | |
---|---|---|
Equals | 判斷指定的物件是否等於目前的物件。 (繼承自 Object)。 | |
Finalize | 在記憶體回收開始前,允許物件嘗試釋放資源,並執行其他清除作業。 (繼承自 Object)。 | |
GetHashCode | 做為預設雜湊函式。 (繼承自 Object)。 | |
GetType | 取得目前實例 Type 的屬性。 (繼承自 Object)。 | |
MemberwiseClone | 建立目前 Object 的淺層複製 (Shallow Copy) 。 (繼承自 Object)。 | |
ToString | 傳回代表目前物件的字串。 (繼承自 Object)。 |
回頁首
備註
使用 DrawItem 事件或 DataRepeaterItem 物件外觀,它們捲動到檢視。
在執行階段,外觀相關屬性可以根據條件進行設定。 例如在排程應用程式中,您可以變更項目的背景色彩,以便在項目過期時警告使用者。 如果您在條件式陳述式 (例如 If…Then),您的屬性也必須使用 Else 子句指定外觀,當條件不符合時。
範例
當項目被捲動到檢視處時,下列範例示範如何使用 DrawItem 事件處理常式中進行變更。 這個範例假設您有一個 DataRepeater 控制項,而且這個控制項已繫結到 Northwind 資料庫中的 Products 資料表。
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;
}
}
執行緒安全
這個類型的任何 Public static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員是安全執行緒。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間