Well, I have managed it somehow with the code that I have put in the comment .
In the class Formthat implements those controls TextBox, you do the following:
You do using System.Runtime.InteropServices;at the beginning of the file MiForm.cs(Where MiFormis the name of the code file corresponding to the Formone you use.)
in this way you will have the events but you control the actions, it will not be as direct as assigning the .Text, but you will not have any cursor on the control
To make the assignment of the number simpler if you don't want to use the Paint event, you could see if with
Graphics g = pictureBox1.CreateGraphics();
or maybe something like
Bitmap bm = new Bitmap(pictureBox1.Width, pictureBox1.Height);
using (Graphics g = Graphics.FromImage(bm))
{
using (SolidBrush myBrush = new SolidBrush(Color.Black))
{
using (Font myFont = new Font("Times New Roman", 24))
{
g.DrawString("aqui numero", myFont, myBrush, 10, 10);
pictureBox1.Image = bm;
}
}
}
when you want to show a number you draw it in an image and assign it to the picturebox, if you need to assign a background color you can always do it without problems
Well, I have managed it somehow with the code that I have put in the comment .
In the class
Form
that implements those controlsTextBox
, you do the following:You do
using System.Runtime.InteropServices;
at the beginning of the fileMiForm.cs
(WhereMiForm
is the name of the code file corresponding to theForm
one you use.)You define the external method
HideCaret
:Then for each
TextBox
you configure the eventGotFocus
as follows:And with that you have what you need to complete the
Form
, below I leave all the code of oneForm1.cs
that I made while I was trying:I would advise you not to use a TextBox to represent each square, you could use a picturebox and draw the number
How to draw text on picturebox?
Drawing Graphics in C Sharp
in this way you will have the events but you control the actions, it will not be as direct as assigning the .Text, but you will not have any cursor on the control
To make the assignment of the number simpler if you don't want to use the Paint event, you could see if with
or maybe something like
when you want to show a number you draw it in an image and assign it to the picturebox, if you need to assign a background color you can always do it without problems