共用方式為


DataRepeaterItemEventArgs 類別

提供 DrawItem 事件的資料。

繼承階層架構

System.Object
  System.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所提供的資料DrawItem事件DataRepeater控制項

回頁首

方法

  名稱 說明
公用方法 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 命名空間

DrawItem

其他資源

DataRepeater 控制項簡介 (Visual Studio)

HOW TO:變更 DataRepeater 控制項的外觀 (Visual Studio)