Reputation: 57
I already could show the tooltip whenever the quantity
less than 5
for that productcode
bound with, but once the tooltip has been shown, it just read the last row of datagridview, not all of the datas inside it.
Here is the image:
From the above image, you can see there are two productcode that has a quantity less than 5, but if you see from the right bottom corner, it just show the last row of the data.
Here is the code that I am using:
void CheckQuantity()
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string productCode = row.Cells[0].Value.ToString();
decimal quantity = Convert.ToDecimal(row.Cells[1].Value);
if (quantity < 5)
{
SystemManager.SoundEffect("C:/Windows/Media/Speech Off.wav");
customToolTip1.Show("- Product Code: " + productCode + "\n- Quantity: " + quantity, this, _screen.Right, _screen.Bottom, 5000);
timeLeft = 15;
_timer.Start();
}
else
{
timeLeft = 15;
_timer.Start();
}
}
}
void Timer_Tick(object sender, EventArgs e)
{
timeLeft--;
if (timeLeft == 0)
{
_timer.Stop();
CheckQuantity();
}
}
void Database_Load(object sender, EventArgs e)
{
_timer.Start();
}
void Database_FormClosed(object sender, FormClosedEventArgs e)
{
_timer.Stop();
}
uint timeLeft = 15;
I appreciate your answer.
Thanks.
Upvotes: 0
Views: 140
Reputation: 1020
It's a bit unclear the result you are expecting, is this what you mean?
void CheckQuantity()
{
string msg = "";
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string productCode = row.Cells[0].Value.ToString();
decimal quantity = Convert.ToDecimal(row.Cells[1].Value);
if (quantity < 5)
{
msg += "- Product Code: " + productCode + " - Quantity: " + quantity + "\n";
}
}
if (msg != "")
{
SystemManager.SoundEffect("C:/Windows/Media/Speech Off.wav");
customToolTip1.Show(msg, this, _screen.Right, _screen.Bottom, 5000);
}
}
void Timer_Tick(object sender, EventArgs e)
{
_timer.Stop();
CheckQuantity();
}
void Database_Load(object sender, EventArgs e)
{
_timer.Interval = 15 * 1000;
_timer.Start();
}
void Database_FormClosed(object sender, FormClosedEventArgs e)
{
_timer.Stop();
}
Upvotes: 1