Avatar of Amitava_Mukherjee
Amitava_MukherjeeFlag for India

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.Width-(Screen.PrimaryScreen.Bounds.Width - Cursor.Position.X)-this.Left-dataGridView1.Left-30);
            int xGridRatio = (int)(dataGridView1.Rows[0].Cells[0].ContentBounds.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
.NET ProgrammingC#

Avatar of undefined
Last Comment
Amitava_Mukherjee
Avatar of adriankohws
adriankohws
Flag of Singapore image

LOL. Not saying it's impossible but just too tedious to do it. Why you just can't make any click and use an option for messagebox to allow user to select, then you do what you wish to do.

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.
Avatar of Amitava_Mukherjee

ASKER

Client is GOD, and we do as client wish :-(

thanx
Avatar of Amitava_Mukherjee

ASKER

So Experts,

No solution?
ASKER CERTIFIED SOLUTION
Avatar of dericstone
dericstone
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Amitava_Mukherjee

ASKER

thanx
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo