Bonjour , mon problème est tres simple pourtant je n ai pas trouver la solution.
Bon une zone de text , textBox quant il recoit le focus il signal ceci ( | ) moi je veux qu'il signale ceci ( _ ).
comme en msDos.
merci de m aider.
Bonjour , mon problème est tres simple pourtant je n ai pas trouver la solution.
Bon une zone de text , textBox quant il recoit le focus il signal ceci ( | ) moi je veux qu'il signale ceci ( _ ).
comme en msDos.
merci de m aider.
Bonjour
Vous pouvez utiliser l'événement OnPaint, tout simplement:
1) Dessinez un rectangle qui couvre le caret (rectangle blanc si la couleur de textbox fond est blanc aussi)
2) Dessiner une chaîne qui va du visible à l'invisible par le temps.
Ça marche pour moi
(Je suggère de jeter un oeil au code SharpDevelop, chemin: src \ Libraries \ ICSharpCode.TextEditor \ Project \ Src \ Gui \ Caret.cs)
bonjour
La seule methode viable pour le faire est un appel à l'API Windows ,car le caret est une resource shared qui impacte le systeme lui-meme...
Lorsque le control TextBox perd le focus ,le caret doit etre restore à ses dimensions par defaut...!!!
simplistic code .cs exemple:
bon code....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WinCustomCaret { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus); } private void Form2_Load(object sender, EventArgs e) { this.textBox1.Text = "If you want the csuror to never be shown in a textbox control, then simply put the HideCaret code in the Textbox_GotFocus() event. Like below "; this.textBox2.Text = "If you want the csuror to never be shown in a textbox control, then simply put the HideCaret code in the Textbox_GotFocus() event. Like below "; this.comboBox1.Items.Add("If you want the csuror to never be shown in a textbox control, then simply put the HideCaret code in the Textbox_GotFocus() event. Like below "); } private void textBox1_GotFocus(object sender, EventArgs e) { // show a block cursor ShowCustomCaret(6, 14); } private void ShowCustomCaret(Int32 width ,Int32 height) { try { CreateCaret(this.ActiveControl.Handle.ToInt32(),0 , width, height); ShowCaret(this.ActiveControl.Handle.ToInt32()); } catch (Exception) { throw; } } [DllImport("user32")] private static extern Int32 CreateCaret(Int32 hWnd, Int32 hBitmap, Int32 nWidth, Int32 nHeight); [DllImport("user32")] private static extern Int32 ShowCaret(Int32 hWnd); [DllImport("user32")] private static extern Int32 HideCaret(Int32 hWnd); } }
Je ne c est pas pourquoi je ne dispose pas de l événement got_focus???!!!
rebonjour
il y a beaucoup d'events qui ne sont pas listes dans le designer mais se trouve dans le fenetre de code !!!
Il est donc derriere les coulisses ou "underhood" (l'arbre qui cache la foret ) !!!
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager