DataGridViewLinkColumn.UseColumnTextForLinkValue 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,指出 Text 屬性值是否會顯示為連結文字。
public:
property bool UseColumnTextForLinkValue { bool get(); void set(bool value); };
public bool UseColumnTextForLinkValue { get; set; }
member this.UseColumnTextForLinkValue : bool with get, set
Public Property UseColumnTextForLinkValue As Boolean
屬性值
如果 Text 屬性值會顯示為連結文字,則為 true
;如果儲存格的 FormattedValue 屬性值會顯示為連結文字,則為 false
。 預設為 false
。
例外狀況
CellTemplate 屬性的值是 null
。
範例
下列程式碼範例示範如何設定這個屬性,如此一來, FormattedValue 每個資料格的 屬性,在此案例中,員工的員工識別碼會顯示為文字連結。 選取連結之後,選取點會移至主管的名稱。 這個範例是類別概觀主題中較大範例的 DataGridViewComboBoxColumn 一部分。
private:
void AddLinkColumn()
{
DataGridViewLinkColumn^ links = gcnew DataGridViewLinkColumn();
links->UseColumnTextForLinkValue = true;
links->HeaderText = ColumnName::ReportsTo.ToString();
links->DataPropertyName = ColumnName::ReportsTo.ToString();
links->ActiveLinkColor = Color::White;
links->LinkBehavior = LinkBehavior::SystemDefault;
links->LinkColor = Color::Blue;
links->TrackVisitedState = true;
links->VisitedLinkColor = Color::YellowGreen;
DataGridView1->Columns->Add(links);
}
private void AddLinkColumn()
{
DataGridViewLinkColumn links = new DataGridViewLinkColumn();
links.UseColumnTextForLinkValue = true;
links.HeaderText = ColumnName.ReportsTo.ToString();
links.DataPropertyName = ColumnName.ReportsTo.ToString();
links.ActiveLinkColor = Color.White;
links.LinkBehavior = LinkBehavior.SystemDefault;
links.LinkColor = Color.Blue;
links.TrackVisitedState = true;
links.VisitedLinkColor = Color.YellowGreen;
DataGridView1.Columns.Add(links);
}
Private Sub AddLinkColumn()
Dim links As New DataGridViewLinkColumn()
With links
.UseColumnTextForLinkValue = True
.HeaderText = ColumnName.ReportsTo.ToString()
.DataPropertyName = ColumnName.ReportsTo.ToString()
.ActiveLinkColor = Color.White
.LinkBehavior = LinkBehavior.SystemDefault
.LinkColor = Color.Blue
.TrackVisitedState = True
.VisitedLinkColor = Color.YellowGreen
End With
DataGridView1.Columns.Add(links)
End Sub
備註
取得或設定這個屬性會取得或設定 UseColumnTextForLinkValue 屬性所 CellTemplate 傳回之物件的 屬性。 設定此屬性也會設定 UseColumnTextForLinkValue 資料行中每個儲存格的 屬性,並重新整理資料行顯示。 若要覆寫個別儲存格的指定值,請在設定資料行值之後設定儲存格值。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應