Reputation: 77
Im having problem with setting my tooltip that will change depending on the button that is targetting on.
This is my form load event to set my tooltip.
private void FrmMain_Load(object sender, EventArgs e)
{
tabView.TabPages.Clear();
toolTip.SetToolTip(btnACust, "Add customer");
toolTip.SetToolTip(btnRCust, "Remove customer");
toolTip.SetToolTip(btnSrch, "Search for an item");
toolTip.SetToolTip(btnRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnEdit, "Edit selected item");
toolTip.SetToolTip(btnDel, "Delete selected item");
toolTip.SetToolTip(btnSell, "Add item to cart");
toolTip.SetToolTip(btnReg, "Sell item/s");
toolTip.SetToolTip(btnCRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnUpd, "Update item");
toolTip.SetToolTip(btnUndo, "Reset to default values");
toolTip.SetToolTip(btnECan, "Cancel all changes and close");
dataGridSales.Columns[3].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("en-PH");
dataGridSales.Columns[3].DefaultCellStyle.Format = String.Format("C2");
dataGridSales.Columns[3].ValueType = typeof(Double);
dataGridSales.Columns[4].Visible = false;
lblTimeDate.Text = "Date: " + System.DateTime.Now.ToShortDateString();
dateTimeToday.Value = System.DateTime.Now;
}
I even tried placing it here.
public FrmMain()
{
InitializeComponent();
toolTip.SetToolTip(btnACust, "Add customer");
toolTip.SetToolTip(btnRCust, "Remove customer");
toolTip.SetToolTip(btnSrch, "Search for an item");
toolTip.SetToolTip(btnRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnEdit, "Edit selected item");
toolTip.SetToolTip(btnDel, "Delete selected item");
toolTip.SetToolTip(btnSell, "Add item to cart");
toolTip.SetToolTip(btnReg, "Sell item/s");
toolTip.SetToolTip(btnCRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnUpd, "Update item");
toolTip.SetToolTip(btnUndo, "Reset to default values");
toolTip.SetToolTip(btnECan, "Cancel all changes and close");
}
But the tooltip doesn't show anything. It will only show if I open my first tab page. If I choose to open other tab pages, it will not show.
This is the event where my first tab page will open
private void productsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!splitContainer1.Panel1.Contains(tabProd))
{
tabView.Visible = true;
tabView.TabPages.Add(tabProd);
tabView.SelectTab(tabProd);
refresh();
}
else
{
tabView.SelectedTab = tabProd;
}
}
All my tabs are open the same way. I'm thinking of MouseHover Event
but I have too many buttons, these are only some of it.
That button is located at my splitcontainer panel 2. Tab pages are open at splitcontainer panel 1. This is the sample of my form load.
The user needs to open this tab page so that the tooltip will show. But I need the tooltip to show even if this tab is not open first.
When my first tab page is open
Since first tab page is open, the tooltip is now showing
Also tooltip doesn't show if other tab page is open.
If the user open other tab page
If the user open other tab page
Upvotes: 0
Views: 404
Reputation: 156
you need to set toolTip.ShowAlways to true.
so your code should look like this:
private void FrmMain_Load(object sender, EventArgs e)
{
tabView.TabPages.Clear();
toolTip.ShowAlways = true;
toolTip.SetToolTip(btnACust, "Add customer");
toolTip.SetToolTip(btnRCust, "Remove customer");
toolTip.SetToolTip(btnSrch, "Search for an item");
toolTip.SetToolTip(btnRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnEdit, "Edit selected item");
toolTip.SetToolTip(btnDel, "Delete selected item");
toolTip.SetToolTip(btnSell, "Add item to cart");
toolTip.SetToolTip(btnReg, "Sell item/s");
toolTip.SetToolTip(btnCRef, "Refresh search criteria and data");
toolTip.SetToolTip(btnUpd, "Update item");
toolTip.SetToolTip(btnUndo, "Reset to default values");
toolTip.SetToolTip(btnECan, "Cancel all changes and close");
dataGridSales.Columns[3].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("en-PH");
dataGridSales.Columns[3].DefaultCellStyle.Format = String.Format("C2");
dataGridSales.Columns[3].ValueType = typeof(Double);
dataGridSales.Columns[4].Visible = false;
lblTimeDate.Text = "Date: " + System.DateTime.Now.ToShortDateString();
dateTimeToday.Value = System.DateTime.Now;
}
Upvotes: 1