Bonjour
J'ai un petit soucis
J'ai 3 forms :
MainForm.xaml.cs
ParamsAffichage.xaml.cs
Selection.xaml.cs
Depuis la MainForm.xaml.cs j'ai un bouton qui ouvre la fenêtre ParamsAffichage.xamls.cs : comme vous pouvez le voir j'ouvre ma 2ème form en ShowDialog et j'attends le retour true de la form ParamsAfficahge.xaml.cs
Depuis la ParamsAffichage.xaml.cs j'ai un bouton qui ouvre la fenêtre Selection.xamls.cs : comme vous pouvez le voir j'ouvre ma 3ème form en ShowDialog et j'attends le retour true de la form Selection.xaml.cs.
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 private void btnParamsAffichage_Click(object sender, RoutedEventArgs e) { dtTimer.Stop(); ParamsAffichage frmParamsAffichage = new ParamsAffichage(); frmParamsAffichage.ShowDialog(); if (frmParamsAffichage.DialogResult.HasValue && frmParamsAffichage.DialogResult.Value) { thrGetList = new Thread(GetList); thrGetList.Start(); if (iValueDefaultSelection != 0) iTimer = iValueDefaultSelection; } else { } this.Effect = null; if (Var.bRefreshAuto) dtTimer.Start(); }
Sauf qu'à ce moment là, j'aimerais cacher la fenêtre ParamsAfficahge.xaml.cs pour pas que les 2 fenêtres soit superposées (pour un côté esthétique) : je fais donc un this.Hide(); et un this.Show(); de ParamsAffichage :
Puis dans la Form Selection.xaml.cs je retourne true une fois terminé :
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 private void btnSelectLigne_Click(object sender, RoutedEventArgs e) { Selection frmSelection = new Selection(Var.lstSelectedLignesChoisi, "Sélection de ligne", "Ligne"); int i = 0; foreach (var item in frmSelection.LstSelection) { if (Var.lstSelectedLignesChoisi.Contains(item.strCode)) { item.bChecked = true; } i++; } //this.WindowState = WindowState.Minimized; this.Hide(); frmSelection.ShowDialog(); if (frmSelection.DialogResult.HasValue && frmSelection.DialogResult.Value) { strSelectionLignes = ""; for (int j = 0; j < Var.lstSelectedLignesChoisi.Count; j++) { strSelectionLignes += Var.lstSelectedLignesChoisi[j].ToString() + " "; } ClearFiltresAndObjects(); Var.lstSelectedIlotsChoisi.Clear(); strSelectionIlots = ""; Var.lstSelectedPostesTravailChoisi.Clear(); strSelectionPostesTravail = ""; } else { } //this.WindowState = WindowState.Normal; this.Show(); }
Le problème : quand je valide (3ème bout de code), la ParamsAffichage.xaml.cs reçoit la réponse dans frmSelection.DialogResult.HasValue && frmSelection.DialogResult.Value mais ensuite la MainForm.xaml.cs reçoit également une réponse, alors que je n'ai pas encore fermé la ParamsAffichage.xaml.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 private void btnValider_Click(object sender, RoutedEventArgs e) { //this.lstSelectedLignesChoisi = lstSelectedLignes; this.DialogResult = true; this.Close(); }
Pourquoi ?
Pour résoudre mon problème, j'ai fais un Minimize de la 2ème form en attendant (en commentaire dans l'exemple)
Cependant j'aimerais comprendre pourquoi j'ai ce problème et savoir comment la cacher
Par avance merci et meilleures salutations.
Partager