DataGridTableStyle.LinkColor プロパティ
リンク テキストの色を取得または設定します。
Public Property LinkColor As Color
[C#]
public Color LinkColor {get; set;}
[C++]
public: __property Color get_LinkColor();public: __property void set_LinkColor(Color);
[JScript]
public function get LinkColor() : Color;public function set LinkColor(Color);
プロパティ値
リンク テキストの Color 。
使用例
Private Sub AddCustomDataTableStyle()
myDataGridTableStyle1 = New DataGridTableStyle()
myDataGridTableStyle2 = New DataGridTableStyle()
MessageBox.Show("LinkColor Before : " & myDataGridTableStyle1.LinkColor.ToString)
MessageBox.Show("HeaderFont Before : " & myDataGridTableStyle1.HeaderFont.ToString)
AddHandler myDataGridTableStyle1.LinkColorChanged, AddressOf LinkColorChanged_Handler
AddHandler myDataGridTableStyle1.HeaderFontChanged, AddressOf HeaderFontChanged_Handler
myDataGridTableStyle1.MappingName = "Customers"
' Set other properties.
myDataGridTableStyle1.AlternatingBackColor = Color.LightGray
myDataGridTableStyle1.LinkColor = Color.Red
myDataGridTableStyle1.HeaderFont = New System.Drawing.Font _
("Verdana", 8.25F, System.Drawing.FontStyle.Bold, _
System.Drawing.GraphicsUnit.Point, CType(0, System.Byte))
' Add a GridColumnStyle and set its MappingName.
Dim myBoolCol = New DataGridBoolColumn()
myBoolCol.MappingName = "Current"
myBoolCol.HeaderText = "IsCurrent Customer"
myBoolCol.Width = 150
myDataGridTableStyle1.GridColumnStyles.Add(myBoolCol)
' Add a second column style.
Dim myTextCol = New DataGridTextBoxColumn()
myTextCol.MappingName = "custName"
myTextCol.HeaderText = "Customer Name"
myTextCol.Width = 250
myDataGridTableStyle1.GridColumnStyles.Add(myTextCol)
' Create new ColumnStyle objects
Dim cOrderDate = New DataGridTextBoxColumn()
cOrderDate.MappingName = "OrderDate"
cOrderDate.HeaderText = "Order Date"
cOrderDate.Width = 100
' PropertyDescriptor to create a formatted column.
Dim myPropertyDescriptorCollection As PropertyDescriptorCollection = _
Me.BindingContext(myDataSet, "Customers.custToOrders").GetItemProperties()
Dim csOrderAmount = New DataGridTextBoxColumn(myPropertyDescriptorCollection _
("OrderAmount"), "c", True)
csOrderAmount.MappingName = "OrderAmount"
csOrderAmount.HeaderText = "Total"
csOrderAmount.Width = 100
' Add the DataGridTableStyle instances to GridTableStylesCollection.
myDataGrid.TableStyles.Add(myDataGridTableStyle1)
End Sub 'AddCustomDataTableStyle
Private Sub LinkColorChanged_Handler(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("LinkColor changed to 'RED'", "DataGridTableStyle")
End Sub 'LinkColorChanged_Handler
Private Sub HeaderFontChanged_Handler(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("HeaderFont changed to 'VERDANA'", "DataGridTableStyle")
End Sub 'HeaderFontChanged_Handler
[C#]
private void AddCustomDataTableStyle()
{
myDataGridTableStyle1 = new DataGridTableStyle();
myDataGridTableStyle2 = new DataGridTableStyle();
MessageBox.Show("LinkColor Before : "
+myDataGridTableStyle1.LinkColor);
MessageBox.Show("HeaderFont Before : "
+myDataGridTableStyle1.HeaderFont);
myDataGridTableStyle1.LinkColorChanged +=
new System.EventHandler(LinkColorChanged_Handler);
myDataGridTableStyle1.HeaderFontChanged
+= new System.EventHandler(HeaderFontChanged_Handler);
myDataGridTableStyle1.MappingName = "Customers";
// Set other properties.
myDataGridTableStyle1.AlternatingBackColor = Color.LightGray;
myDataGridTableStyle1.LinkColor = Color.Red;
myDataGridTableStyle1.HeaderFont =
new System.Drawing.Font("Verdana",
8.25F,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
// Add a GridColumnStyle and set its MappingName.
DataGridColumnStyle myBoolCol = new DataGridBoolColumn();
myBoolCol.MappingName = "Current";
myBoolCol.HeaderText = "IsCurrent Customer";
myBoolCol.Width = 150;
myDataGridTableStyle1.GridColumnStyles.Add(myBoolCol);
// Add a second column style.
DataGridColumnStyle myTextCol = new DataGridTextBoxColumn();
myTextCol.MappingName = "custName";
myTextCol.HeaderText = "Customer Name";
myTextCol.Width = 250;
myDataGridTableStyle1.GridColumnStyles.Add(myTextCol);
// Create new ColumnStyle objects
DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn();
cOrderDate.MappingName = "OrderDate";
cOrderDate.HeaderText = "Order Date";
cOrderDate.Width = 100;
// PropertyDescriptor to create a formatted column.
PropertyDescriptorCollection myPropertyDescriptorCollection = this.BindingContext
[myDataSet, "Customers.custToOrders"].GetItemProperties();
DataGridColumnStyle csOrderAmount =
new DataGridTextBoxColumn(myPropertyDescriptorCollection["OrderAmount"], "c", true);
csOrderAmount.MappingName = "OrderAmount";
csOrderAmount.HeaderText = "Total";
csOrderAmount.Width = 100;
// Add the DataGridTableStyle instances to GridTableStylesCollection.
myDataGrid.TableStyles.Add(myDataGridTableStyle1);
}
private void LinkColorChanged_Handler(object sender,EventArgs e)
{
MessageBox.Show("LinkColor changed to 'RED'", "DataGridTableStyle");
}
private void HeaderFontChanged_Handler(object sender,EventArgs e)
{
MessageBox.Show("HeaderFont changed to 'VERDANA'",
"DataGridTableStyle");
}
[C++]
private:
void AddCustomDataTableStyle() {
myDataGridTableStyle1 = new DataGridTableStyle();
myDataGridTableStyle2 = new DataGridTableStyle();
MessageBox::Show(String::Concat(S"LinkColor Before : ",
__box( myDataGridTableStyle1->LinkColor)));
MessageBox::Show(String::Concat(S"HeaderFont Before : ",
myDataGridTableStyle1->HeaderFont));
myDataGridTableStyle1->LinkColorChanged +=
new System::EventHandler(this, &DataGridTableStyle_Sample::LinkColorChanged_Handler);
myDataGridTableStyle1->HeaderFontChanged +=
new System::EventHandler(this, &DataGridTableStyle_Sample::HeaderFontChanged_Handler);
myDataGridTableStyle1->MappingName = S"Customers";
// Set other properties.
myDataGridTableStyle1->AlternatingBackColor = Color::LightGray;
myDataGridTableStyle1->LinkColor = Color::Red;
myDataGridTableStyle1->HeaderFont = new System::Drawing::Font(S"Verdana",
8.25F,
System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::Point,
((System::Byte)(0)));
// Add a GridColumnStyle and set its MappingName.
DataGridColumnStyle* myBoolCol = new DataGridBoolColumn();
myBoolCol->MappingName = S"Current";
myBoolCol->HeaderText = S"IsCurrent Customer";
myBoolCol->Width = 150;
myDataGridTableStyle1->GridColumnStyles->Add(myBoolCol);
// Add a second column style.
DataGridColumnStyle* myTextCol = new DataGridTextBoxColumn();
myTextCol->MappingName = S"custName";
myTextCol->HeaderText = S"Customer Name";
myTextCol->Width = 250;
myDataGridTableStyle1->GridColumnStyles->Add(myTextCol);
// Create new ColumnStyle objects
DataGridColumnStyle* cOrderDate = new DataGridTextBoxColumn();
cOrderDate->MappingName = S"OrderDate";
cOrderDate->HeaderText = S"Order Date";
cOrderDate->Width = 100;
// PropertyDescriptor to create a formatted column.
PropertyDescriptorCollection* myPropertyDescriptorCollection =
this->BindingContext->get_Item(myDataSet,
S"Customers.custToOrders")->GetItemProperties();
DataGridColumnStyle* csOrderAmount =
new DataGridTextBoxColumn(
myPropertyDescriptorCollection->Item[S"OrderAmount"], S"c", true);
csOrderAmount->MappingName = S"OrderAmount";
csOrderAmount->HeaderText = S"Total";
csOrderAmount->Width = 100;
// Add the DataGridTableStyle instances to GridTableStylesCollection.
myDataGrid->TableStyles->Add(myDataGridTableStyle1);
}
void LinkColorChanged_Handler(Object* /*sender*/, EventArgs* /*e*/) {
MessageBox::Show(S"LinkColor changed to 'RED'", S"DataGridTableStyle");
}
void HeaderFontChanged_Handler(Object* /*sender*/, EventArgs* /*e*/) {
MessageBox::Show(S"HeaderFont changed to 'VERDANA'",
S"DataGridTableStyle");
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
DataGridTableStyle クラス | DataGridTableStyle メンバ | System.Windows.Forms 名前空間 | LinkColorChanged | ShouldSerializeLinkColor