Bonjour,
Savez vous comment on fait pour obtenir l'index d'un tabpage selon ces coordonnées .Je coince un peux .
Merci
.
Stéphanie
Version imprimable
Bonjour,
Savez vous comment on fait pour obtenir l'index d'un tabpage selon ces coordonnées .Je coince un peux .
Merci
.
Stéphanie
Bonjour,
Code:
1
2 monTabControl.GetChildAtPoint(New Point(posX, posY));
tu sais comment obtenir les coordonnées de ma tabpage selectionné j'ai essayé :
Mais les valeur ne change pas .Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 private void tabControl1_MouseDown(object sender, MouseEventArgs e) { int X = this.tabControl1.SelectedTab.Bounds.X ; int Y = this.tabControl1.SelectedTab.Bounds.Y ; if (e.Button == MouseButtons.Right) { if (X == 4 && Y == 23) { contextMenuStrip2.Show(this.tabControl1, e.X, e.Y); this.tabControl1.SelectedIndex = 2; } } }
Quels cordonnées veut tu obtenir ? Celle de l'onglet du TabControl ou celle du contenu du TabPage ?
Pour les onglets
Code:
1
2 MsgBox(monTabControl.GetTabRect(indexDeMonOnglet).ToString());
je cherche du type
Y =
X=
Je vais pas tout de donner non plus..
Code:
1
2
3 monTabControl.GetTabRect(indexDeMonOnglet).X; monTabControl.GetTabRect(indexDeMonOnglet).Y;
d'accord merci je vais tester ca
j'ai fait la fonction suivante ou j'essaye de renvoyer l'index de mon onglet
En faite comment comparer la zone rectangulaire et le point du curseur ?Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 private int RetourIndex(int X, int Y) { int index = 0; for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if (this.tabControl1.TabPages[i].Bounds.X == X && this.tabControl1.TabPages[i].Bounds.Y == Y) { index = i; break; } } return index; }
Code:
1
2 TabControl1.GetTabRect(1).Contains(MousePosition);
merci pour ton aide jerede
voila le code finale
Code:
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 private void tabControl1_MouseDown(object sender, MouseEventArgs e) { int X= 0; X = this.tabControl1.GetTabRect(this.tabControl1.SelectedIndex).X; int Y = 0; Y = this.tabControl1.GetTabRect(this.tabControl1.SelectedIndex).Y; //this.tabControl1.GetTabRect(this.tabControl1.SelectedIndex); if (e.Button == MouseButtons.Right) { int index = 0; for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if ( this.tabControl1.GetTabRect(i).Contains(e.X, e.Y) == true ) { index = i; break; } } if (X != 0 && Y != 0) { contextMenuStrip2.Show(this.tabControl1, e.X, e.Y); // this.tabControl1.SelectedIndex = this.tabControl1.GetTabRect(e.Y, e.Y); // this.tabControl1.GetTabRect(this.tabControl1.SelectedIndex); this.tabControl1.SelectedIndex = index; ; } } }