Amitava_Mukherjee
asked on
Datagridviewcell content detect by C#
I asked a question to EE you may find below:
I have a datagridview cell containing the following text
" + This is test"
Now I want to show a messagebox sowing message "+" if the mouse clicked on the + sign (In a single cell), and another messagebox "This is test" if mouse clicked on the rest portion. The whole string is showing in a single DataGridViewTextboxCell.
Is it possible? If it is, kindly send me the code in C#.
EE answered me the following (starlite551: had gave me the solution)
int xOffSet = (int)(Screen.PrimaryScreen .Bounds.Wi dth-(Scree n.PrimaryS creen.Boun ds.Width - Cursor.Position.X)-this.Le ft-dataGri dView1.Lef t-30);
int xGridRatio = (int)(dataGridView1.Rows[0 ].Cells[0] .ContentBo unds.Width / 2);
if(xOffSet < xGridRatio)
{
MessageBox.Show("+");
}
else
{
MessageBox.Show("This is test");
}
It is working fine when the column is the left first column in datagridview but do not work if it is not the left most column
any suggestion?
thanking you
I have a datagridview cell containing the following text
" + This is test"
Now I want to show a messagebox sowing message "+" if the mouse clicked on the + sign (In a single cell), and another messagebox "This is test" if mouse clicked on the rest portion. The whole string is showing in a single DataGridViewTextboxCell.
Is it possible? If it is, kindly send me the code in C#.
EE answered me the following (starlite551: had gave me the solution)
int xOffSet = (int)(Screen.PrimaryScreen
int xGridRatio = (int)(dataGridView1.Rows[0
if(xOffSet < xGridRatio)
{
MessageBox.Show("+");
}
else
{
MessageBox.Show("This is test");
}
It is working fine when the column is the left first column in datagridview but do not work if it is not the left most column
any suggestion?
thanking you
ASKER
Client is GOD, and we do as client wish :-(
thanx
thanx
ASKER
So Experts,
No solution?
No solution?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanx
Using such concept, your programming work will be hell lot than what other need to do, you are killing yourself. You must identify the left bound of the actual cell which the user clicks and work from there and maybe even your end users don't know there's a difference clicking on the text or "+" sign itself.