DataRepeater.DrawItem イベント
発生したときに、DataRepeaterItem描画する必要があります。
名前空間: Microsoft.VisualBasic.PowerPacks
アセンブリ: Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)
構文
'宣言
Public Event DrawItem As DataRepeaterItemEventHandler
public event DataRepeaterItemEventHandler DrawItem
public:
event DataRepeaterItemEventHandler^ DrawItem {
void add (DataRepeaterItemEventHandler^ value);
void remove (DataRepeaterItemEventHandler^ value);
}
member DrawItem : IEvent<DataRepeaterItemEventHandler,
DataRepeaterItemEventArgs>
JScript では、イベントは使用できません。
解説
このイベントの外観の変更を使用してDataRepeaterItemオブジェクトは、スクロールして表示します。
実行時に、外観に関するプロパティが設定できます条件に基づいてように各項目がビューにスクロールされたとき。 たとえば、アプリケーションでは、スケジュール、項目は期限があるとユーザーに警告するアイテムの背景色を変更する場合があります。 If you set a property in a conditional statement such as If…Then, you must also use an Else clause to specify the appearance when the condition is not met.
イベントを処理する方法の詳細については、次を参照してください。イベントの処理と発生です。
例
いくつかの一般的なカスタマイズ、DataRepeaterコントロールには行を表示する色を交互に、条件に基づくフィールドの色の変更が含まれます。 次の例は、これらのカスタマイズを実行する方法を示します。 この例では、ある、 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;
}
}
.NET Framework セキュリティ
- 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。
参照
関連項目
Microsoft.VisualBasic.PowerPacks 名前空間