0
是否有可能從當前顯示的標籤打開(顯示)的任何值?嘗試突出顯示相鄰/相應的選項卡/鏈接標籤。C#脫節鏈接標籤導航TabControl - 如何突出顯示當前標籤打開鏈接標籤
我使用鏈接標籤作爲選項卡的導航。項目完成時,真實(醜陋的頂部)標籤將隱藏。
//LINK LABELS CLICK EVENTS TO DISPLAY/OPEN TABS
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 0;
//COLOURS TO BE APPLIED WHEN THE CORRESPONDING TAB IS OPEN
linkLabel1.BackColor = Color.Black;
linkLabel1.ForeColor = Color.White;
linkLabel1.ActiveLinkColor = System.Drawing.Color.White;
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 1;
txtFirstName.Focus();
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 2;
}
@Idle_Mind答案後,我仍然不知道如何綁定/ wireup事件。這是任何人都具有同樣的問題:
//LINK LABELS CLICK EVENTS TO DISPLAY/OPEN TABS
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 0;
labels_LinkClicked(sender, e);
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 1;
txtFirstName.Focus();
labels_LinkClicked(sender, e);
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
tabControl1.SelectedIndex = 2;
labels_LinkClicked(sender, e);
}
//METHOD TO CALL ON EACH CLICK OF LINK LABELS
private void labels_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
LinkLabel lbl = (LinkLabel)sender;
tabControl1.SelectedIndex = labels.IndexOf(lbl);
foreach (LinkLabel curLbl in labels)
{
curLbl.BackColor = (lbl == curLbl) ? Color.Black : Color.Transparent;
}
}
謝謝@Idle_Mind的幫助。次要更新我將上面的(連線)更改爲您的建議,將未當前標籤背景更改爲透明並在表單加載(linkLabel1.BackColor = Color.Black;)時將LinkLabel1 bg顏色改爲黑色。真棒。謝啦! – Kerry7777