bonjour
je voudrais Synchroniser le défillement de plusieures listbox en utilisant vb.net mais je ne trouve pas léquivalent de l'évnement scroll dont j'ai l'habitude en vb6
si qlq un veut bien m'aider je lui serai reconnaissant
merçi
xc
xcxc
bonjour
je voudrais Synchroniser le défillement de plusieures listbox en utilisant vb.net mais je ne trouve pas léquivalent de l'évnement scroll dont j'ai l'habitude en vb6
si qlq un veut bien m'aider je lui serai reconnaissant
merçi
Si tu utilises WinForm
http://msdn.microsoft.com/en-us/libr...ar.scroll.aspx
Si tu utilises WPF
http://msdn.microsoft.com/en-us/libr...llchanged.aspx
bonjour
merçi pour ton aide meme si ce n'est pas la réponse voulue.
j'ai 3 listbox et je voudrais lorsque je déplace par la souris le scrollbar d'une listbox les scrollbar des deux autres listbox suivent ce mouvent
Le principe est de passer les messages de scroll aux autres listbox par message. Tu trouvera plus de détails par la
http://social.msdn.microsoft.com/for...-7879916f8b18/
Il faut juste que tu l'adaptes un petit peu pour gérer 3 listbox
Bonjour
tout d'abord je m'éxcuse pour le dérrangement!!
Votre aide m'est trés précieuse et merçi beaucoup
seulement j'ai encore un petit problème:
voila j'ai 3 listbox et veux envoyer le message à partir de chaque listbox
comme ci_dessous:
là le programme plante et m'envoie le message suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub Listbox1_Scroll(ByRef m As System.Windows.Forms.Message) Handles ListBox1.Scroll SendMessage(ListBox2.Handle, m.Msg, m.WParam, m.LParam) SendMessage(ListBox3.Handle, m.Msg, m.WParam, m.LParam) End Sub Private Sub ListBox2_Scroll(ByRef m As System.Windows.Forms.Message) Handles ListBox2.Scroll SendMessage(ListBox1.Handle, m.Msg, m.WParam, m.LParam) SendMessage(ListBox3.Handle, m.Msg, m.WParam, m.LParam) End Sub Private Sub ListBox3_Scroll(ByRef m As System.Windows.Forms.Message) Handles ListBox3.Scroll SendMessage(ListBox2.Handle, m.Msg, m.WParam, m.LParam) SendMessage(ListBox1.Handle, m.Msg, m.WParam, m.LParam) End Subpar contre si j'utilise une seule sub tout marche bienUne exception non gérée du type 'System.StackOverflowException' s'est produite dans System.Windows.Forms.dll
par conséquant j'aimerais que vous me donniez encore une petite aide et merçi
je vous envoie le fichier pour voir!!
Quand tu scroll le listbox1 il envoie un message au listbox2 qui lui même va envoyer un message au listbox1 qui renvoie un message au listbox2 ....... D'où le stackoverflow.là le programme plante et m'envoie le message suivant "Une exception non gérée du type 'System.StackOverflowException' s'est produite dans System.Windows.Forms.dll"
Il faut que tu fasses en sorte de ne pas renvoyer le message au listbox d'où le scroll a réellement été fait.
Mon code est en c#
PS : penses à mettre les balises 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 private List<object> from = null; public Form1() { InitializeComponent(); for (int i = 0; i < 1000; i++) { myListBox1.Items.Add(i); } for (int i = 0; i < 1000; i++) { myListBox2.Items.Add(i); } for (int i = 0; i < 1000; i++) { myListBox3.Items.Add(i); } from = new List<object>(); myListBox1.Scroll += new MessageHandler(myListBox1_Scroll); myListBox2.Scroll += new MessageHandler(myListBox1_Scroll); myListBox3.Scroll += new MessageHandler(myListBox1_Scroll); } void myListBox1_Scroll(object sender, Message m) { from.Add(sender); if (!from.Contains(myListBox1)) SendMessage(myListBox1.Handle, m.Msg, m.WParam, m.LParam); if (!from.Contains(myListBox2)) SendMessage(myListBox2.Handle, m.Msg, m.WParam, m.LParam); if (!from.Contains(myListBox3)) SendMessage(myListBox3.Handle, m.Msg, m.WParam, m.LParam); from.Remove(sender); }
Bonjour
Pardonnez moi encore ce dérrangement et merçi d'avance.
je crois comprendre le message d'erreur à travers les lignes de code que vous m'avez envoyé.seulement si vous pouviez me traduire en VB je serais trés satisfait .
mes respects à vous qui etes trés patient avec mes questions.
Quel est le message ?je crois comprendre le message d'erreur à travers les lignes de code que vous m'avez envoyé
http://www.developerfusion.com/tools.../csharp-to-vb/seulement si vous pouviez me traduire en VB je serais trés satisfait .
Bonjour
voila le code aprés migration vers Vb.net
je reçois tjrs le meme message ,alors si vousvoulez bien me corriger l'erreur
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 Public Class Form1 Private from As List(Of Object) = Nothing Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hdl As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr Friend WithEvents MyListBox1 As MyListBox Friend WithEvents MyListBox2 As MyListBox Friend WithEvents MyListBox3 As MyListBox Private Sub myListBox1_Scroll(ByVal sender As Object, ByRef m As Message) from.Add(sender) If Not from.Contains(MyListBox1) Then SendMessage(MyListBox1.Handle, m.Msg, m.WParam, m.LParam) End If If Not from.Contains(MyListBox2) Then SendMessage(MyListBox2.Handle, m.Msg, m.WParam, m.LParam) End If If Not from.Contains(MyListBox3) Then SendMessage(MyListBox3.Handle, m.Msg, m.WParam, m.LParam) End If from.Remove(sender) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load MyListBox1 = New MyListBox MyListBox2 = New MyListBox MyListBox3 = New MyListBox Me.MyListBox1.Location = New System.Drawing.Point(300, 100) Me.MyListBox1.Name = "MyListBox1" Me.MyListBox1.Size = New System.Drawing.Size(182, 224) Me.MyListBox1.TabIndex = 0 Me.MyListBox2.Location = New System.Drawing.Point(482, 100) Me.MyListBox2.Name = "MyListBox2" Me.MyListBox2.Size = New System.Drawing.Size(182, 224) Me.MyListBox2.TabIndex = 1 Me.MyListBox3.Location = New System.Drawing.Point(664, 100) Me.MyListBox3.Name = "MyListBox3" Me.MyListBox3.Size = New System.Drawing.Size(182, 224) Me.MyListBox2.TabIndex = 2 Me.Controls.Add(Me.MyListBox1) Me.Controls.Add(Me.MyListBox2) Me.Controls.Add(Me.MyListBox3) For i As Integer = 0 To 999 MyListBox1.Items.Add(i) Next For i As Integer = 0 To 999 MyListBox2.Items.Add(i) Next For i As Integer = 0 To 999 MyListBox3.Items.Add(i) Next from = New List(Of Object)() AddHandler MyListBox1.Scroll, AddressOf myListBox1_Scroll AddHandler MyListBox2.Scroll, AddressOf myListBox1_Scroll AddHandler MyListBox3.Scroll, AddressOf myListBox1_Scroll 'MyListBox1.Scroll += New MessageHandler(AddressOf myListBox1_Scroll) 'MyListBox2.Scroll += New MessageHandler(AddressOf myListBox1_Scroll) 'MyListBox3.Scroll += New MessageHandler(AddressOf myListBox1_Scroll) End Sub End Class
Quel est ce message ?je reçois tjrs le meme message
bonsoir
le message que je reçois est encore
je dis seulement que le code ne donne rien et j'aimerais que vous donneriez encore un petit coup de main.Une exception non gérée du type 'System.StackOverflowException' s'est produite dans System.Windows.Forms.dll
le code que je vous ai envoyé est à corriger par vous et merçi
bonjour sidisadmirable
Fabulous click,c'est simple il peut te permettre avec la methode ListBox.Select() de synchroniser admirablement ya sidi 3 listboxes sans passer par SendMessage qui lui franchit les frontieres des processus.
voici l'astuce vb.net mais il fallait y penser parbleu :
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 Public Class myForm1 Public Sub New() ' Cet appel est requis par le Concepteur Windows Form. InitializeComponent() ' Ajoutez une initialisation quelconque après l'appel InitializeComponent(). End Sub Private Sub btnFillListBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillListBox1.Click MyListBox1.Items.Clear() MyListBox2.Items.Clear() MyListBox3.Items.Clear() For i As Integer = 0 To 999 MyListBox1.Items.Add(i) Next For i As Integer = 0 To 999 MyListBox2.Items.Add(i) Next For i As Integer = 0 To 999 MyListBox3.Items.Add(i) Next End Sub Private Sub MyListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox1.Click MyListBox2.SetSelected(MyListBox1.SelectedIndex, True) MyListBox2.Focus() MyListBox3.SetSelected(MyListBox1.SelectedIndex, True) MyListBox3.Focus() MessageBox.Show(" MyListBox1") End Sub Private Sub MyListBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox2.Click MyListBox1.SetSelected(MyListBox2.SelectedIndex, True) MyListBox1.Focus() MyListBox3.SetSelected(MyListBox2.SelectedIndex, True) MyListBox3.Focus() MessageBox.Show(" MyListBox2") End Sub Private Sub MyListBox3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox3.Click MyListBox2.SetSelected(MyListBox3.SelectedIndex, True) MyListBox1.Focus() MyListBox1.SetSelected(MyListBox3.SelectedIndex, True) MyListBox1.Focus() MessageBox.Show(" MyListBox3") End Sub End Class
bonjour
premièrement je vous remrçie pour ton aide , seulement moi , je voudrais que lorsque je déplace un un élément ds une listbox ce déplacement doit etre le meme ds les autres listbox c.à.d si je déplace par ex.l'élément d'indice 5 ds la listbox1 ,automatiquement l'élément du meme indice (5) se déplce ds les autres listbox et cela ds le meme sens.
le code de mr.meziantou donne le résultat que j'espère mais seulemnt pour une seule listbox.
le résultat que tu m'as donné je l'ai obtenu par les sub suivantes:
je cherche à synchroniser les listbox par l'événement listbox.scroll
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub MyListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox1.Click MyListBox2.SelectedItem=MyListBox1.SelectedItem MyListBox3.SelectedItem=MyListBox1.SelectedItem End Sub Private Sub MyListBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox2.Click MyListBox1.SelectedItem=MyListBox2.SelectedItem MyListBox3.SelectedItem=MyListBox2.SelectedItem End Sub Private Sub MyListBox3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyListBox3.Click MyListBox1.SelectedItem=MyListBox1.SelectedItem MyListBox2.SelectedItem=MyListBox1.SelectedItem End Sub
bonjour
le problème a été résoulu en corrigeant l'événement scroll au niveau de lamerçi à syvc64
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 classe MylistBox Public Class MyListbox Inherits ListBox Public Event Scroll(ByVal sender As Object, ByRef m As Message) Private Const WM_VSCROLL As Integer = &H115 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_VSCROLL Then RaiseEvent Scroll(Me, m) MyBase.WndProc(m) End Sub End Class Public class Form Private from As List(Of Object) = Nothing Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hdl As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load LstCode = New MyListbox LstNom = New MyListbox LstLang = New MyListbox ' 'LstCode ' Me.LstCode.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.LstCode.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold) Me.LstCode.FormattingEnabled = True Me.LstCode.ItemHeight = 16 Me.LstCode.Location = New System.Drawing.Point(158, 286) Me.LstCode.Name = "LstCode" Me.LstCode.ScrollAlwaysVisible = True Me.LstCode.Size = New System.Drawing.Size(118, 250) Me.LstCode.TabIndex = 27 ' 'LstNom ' Me.LstNom.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.LstNom.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold) Me.LstNom.FormattingEnabled = True Me.LstNom.ItemHeight = 16 Me.LstNom.Location = New System.Drawing.Point(276, 286) Me.LstNom.Name = "LstNom" Me.LstNom.ScrollAlwaysVisible = False Me.LstNom.Size = New System.Drawing.Size(310, 250) Me.LstNom.TabIndex = 28 ' 'LstLang ' Me.LstLang.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.LstLang.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold) Me.LstLang.FormattingEnabled = True Me.LstLang.ItemHeight = 16 Me.LstLang.Location = New System.Drawing.Point(586, 286) Me.LstLang.Name = "LstLang" Me.LstLang.ScrollAlwaysVisible = False Me.LstLang.Size = New System.Drawing.Size(98, 250) Me.LstLang.TabIndex = 29 Me.Controls.Add(Me.LstCode) Me.Controls.Add(Me.LstNom) Me.Controls.Add(Me.LstLang) from = New List(Of Object)() AddHandler LstCode.Scroll, AddressOf LstCode_Scroll AddHandler LstNom.Scroll, AddressOf LstCode_Scroll AddHandler LstLang.Scroll, AddressOf LstCode_Scroll end sub Private Sub LstCode_Scroll(ByVal sender As Object, ByRef m As Message) from.Add(sender) If Not from.Contains(LstCode) Then SendMessage(LstCode.Handle, m.Msg, m.WParam, m.LParam) End If If Not from.Contains(LstNom) Then SendMessage(LstNom.Handle, m.Msg, m.WParam, m.LParam) End If If Not from.Contains(LstLang) Then SendMessage(LstLang.Handle, m.Msg, m.WParam, m.LParam) End If from.Remove(sender) End Sub end classe
Partager