Bonjour, je travail en ce moment sur un projet en C#.
J'aimerais associer une barre de recherche a celui-ci.

Outils :

- 3 textBox (textBox1; textBox2; textBox3)
- 1 Button

textBox1 : textBox principe ou je veux effectué une recherche
textBox2 : je lui demande de recherchez un offset (valeur hexadecimal)
textBox3 : je lui demande de recherchez un byte
Button1 : Faire une recherche

Mis en situation :

J'ai une premiére textbox ou est affichez un tas de valeur hexadecimal (http://prntscr.com/28uzyz), je voudrais que depuis ma textbox2 je puisse réaliser une recherche dans ma textbox1 et pareil pour la textbox3. Une fois l'une des 2 textBox remplis je voudrais que quand je clique sur "Serach" (Button1) il fasse une recherche dans ma textBox1 et m'affiche son emplacement sur ma textBox1.

Code :

Button (Ouvrire document) :
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 textBox3.Text = "";
 
            openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = "C:";
            openFileDialog1.Filter = "Txt file (*.txt)|*.txt|" +
                                          "All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
 
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fileName = openFileDialog1.FileName;
                string message = fileName + " ";
 
            }
            int fsize = getFileSize(fileName);
            if (fsize > 0)
            {
                hexEditor(fileName, fsize);
            }
            else
            {
                textBox3.AppendText("\n An error as occured:\n\n- Select files\n- Files is more bigger");
            }
            openFileDialog1.Dispose();
        }
        private void hexEditor(string inFile, int inSize)
        {
            StringBuilder biglocal = new StringBuilder();
            StringBuilder sblocal = new StringBuilder();
            string file = "Parent directory: " + fileName;
            string encryptish = "\nLength: " + inSize + " bytes\n\n";
            string dmt = "\n Offset(h)   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11\n\n";
            label2.Text = inSize + " bytes";
 
            textBox3.AppendText(file);
            textBox3.AppendText(encryptish);
            textBox3.AppendText(dmt);
 
 
            textBox3.Update();
 
 
            FileStream fs;
            byte[] MyData;
            try
            {
                fs = new FileStream
                    (inFile, FileMode.OpenOrCreate, FileAccess.Read);
                MyData = new byte[fs.Length];
            }
            catch
            {
                textBox3.AppendText
                    ("\n File error or file size to big for byte[] Array\n\n");
                return;
            }
 
 
 
            fs.Read(MyData, 0, (int)fs.Length);
            fs.Close();
 
            int newrow = 0;
            int global = 0;
            string hex = " ";
            string numb = " ";
 
 
            for (int i = 0; i < MyData.Length; ++i)
            {
                if (i % 1000 == 0)
                {
 
                }
 
                if (newrow == 0)
                {
                    numb = padZeros(global);
                    biglocal.Append(" " + numb + " ");
                    global += 16;
                }
 
                hex = convertByteToHexString(MyData[i]);
                biglocal.Append(" " + hex);
 
                int g = MyData[i];
                if (g > 13 || (g > 0 && g < 9))
                {
                    sblocal.Append((char)MyData[i]);
                }
                else
                {
                    sblocal.Append(".");
                }
 
                ++newrow;
 
                if (newrow >= 16)
                {
                    biglocal.Append("   " + sblocal.ToString() + "\n");
                    sblocal = new StringBuilder();
                    newrow = 0;
 
                }
 
 
            }
 
 
            if (newrow > 0 && newrow < 16)
            {
                for (int i = 0; i < (16 - newrow); ++i)
                {
                    biglocal.Append("   ");
                }
                biglocal.Append("   " + sblocal);
            }
            biglocal.Append("\n\n");
 
            textBox3.AppendText(biglocal.ToString());
        }
Je voudrais donc faire une recherche dans le document que j'ouvre.

Merci d'avance et bonne journée.
Cordialement Encryptish.