Click here to Skip to main content
15,879,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a datagridview and some of the columns there are textboxes within the grid.
I want to code it so when user clicks into the textbox it populates the text with a hardcode string value1, if they click on it twice then it populates with hardcode string value2, then if they click on it three times it clears text box and starts again, so click again populates with value1 and so on.

Using c#, within visual studio 2019.

What I have tried:

Not sure how to begin and couldnt find much on internet.

1 solution

Capture the TextBox click command and keep track of how many times the user clicks on the TextBox.

The TextBox class is here[^]

Since you have several TextBoxes I would use the Tag property to keep track of number of clicks.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900