Info sur une fonction et un panel

Résolu
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014 - 24 févr. 2006 à 10:47
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014 - 24 févr. 2006 à 13:07
bonjour j'aurrait une petite question qui conserne les panels voila en faite j'ai une fonction qui crée par le code des controles (trackbar,label,etc...) et j'aimerai afficher ses contrôle dans le panel que j'ai placer sur ma form,mais je ne voit pas le code qui permetterai de faire cela.

8 réponses

MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
24 févr. 2006 à 12:27
Tu remplaces les this.Controls.Add(leControl);
par des this.tonPanel.Controls.Add(leControl);

Et voila


Mx
MVP C#
3
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
24 févr. 2006 à 10:49
Salut,

tonPanel.Controls.Add(tonControl); ca devrait etre suffisant



Mx
MVP C#
0
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014
24 févr. 2006 à 11:11
oui sa je sait, mais excuse moi je me suis mal exprimer en faite je récupère les trackbar, label,et checkbox du mixer audio windows , en faite la fonction les dessines et les place sur la form ,simplement je pense que je ne sait pas récupéré chaque controle vu qu'il passe par une boucle pour récupérer chaque controle.
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
24 févr. 2006 à 11:16
A vrai dire, la j'ai pas compris grand chose.
Peut-etre qu'en nous postant ta fonction, on y verrait plus clair ?



Mx
MVP C#
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014
24 févr. 2006 à 11:32
bon la voici c'est celle qui crée les contrôles


private
void LoadLines(MixerType mixerType)


{



//Reload Line. Clear old controls



if (tBarArray[(
int) mixerType] !=
null)



for(
int i=0;i<tBarArray[(
int) mixerType].Length;i++)


{


tBarArray[(
int) mixerType][i].ValueChanged -=
new System.EventHandler(
this.tBar_ValueChanged);


tBarArray[(
int) mixerType][i].Dispose();


tBarBalanceArray[(
int) mixerType][i].Dispose();


lblArray[(
int) mixerType][i].Dispose();


chkBoxArray[(
int) mixerType][i].Dispose();



this.Controls.Remove(tBarArray[(
int) mixerType][i]);



this.Controls.Remove(tBarBalanceArray[(
int) mixerType][i]);



this.Controls.Remove(lblArray[(
int) mixerType][i]);



this.Controls.Remove(chkBoxArray[(
int) mixerType][i]);


}


MixerLines lines;



//Get info about the lines



if (mixerType == MixerType.Recording)


{


mMixers.Recording.DeviceId = ((MixerDetail) cboInputDevices.SelectedItem).DeviceId;


lines = mMixers.Recording.UserLines;


}



else


{


mMixers.Playback.DeviceId = ((MixerDetail) cboOutputDevices.SelectedItem).DeviceId;


lines = mMixers.Playback.UserLines;


}


tBarArray[(
int) mixerType] =
new TrackBar[lines.Count];


tBarBalanceArray[(
int) mixerType] =
new TrackBar[lines.Count];


lblArray[(
int) mixerType] =
new Label[lines.Count];


chkBoxArray[(
int) mixerType] =
new CheckBox[lines.Count];



//foreach(MixerLine line in lines)



for(
int i=0;i<lines.Count;i++)


{


MixerLine line = lines[i];



// TrackBar creation



this.tBarArray[(
int) mixerType][i] =
new System.Windows.Forms.TrackBar();



this.tBarArray[(
int) mixerType][i].LargeChange = 10000;



this.tBarArray[(
int) mixerType][i].Location =
new System.Drawing.Point(i * 60 + 10, 120 + (
int) mixerType * 225);



this.tBarArray[(
int) mixerType][i].Maximum = 65535;



this.tBarArray[(
int) mixerType][i].Name = "tBarArray" + ((
int) mixerType).ToString() + i.ToString();



this.tBarArray[(
int) mixerType][i].Orientation = Orientation.Vertical;



this.tBarArray[(
int) mixerType][i].Size =
new System.Drawing.Size(45, 100);



this.tBarArray[(
int) mixerType][i].SmallChange = 6553;



this.tBarArray[(
int) mixerType][i].TabIndex = i;



this.tBarArray[(
int) mixerType][i].TickFrequency = 6553;



this.tBarArray[(
int) mixerType][i].TickStyle = System.Windows.Forms.TickStyle.Both;



this.tBarArray[(
int) mixerType][i].Tag = line;



//If it is 2 channels then ask both and set the volume to the bigger but keep relation between them (Balance)



int volume = 0;



float balance = 0;



if (lines[i].Channels != 2)


volume = lines[i].Volume;



else


{


lines[i].Channel = Channel.Left;



int left = lines[i].Volume;


lines[i].Channel = Channel.Right;



int right = lines[i].Volume;



if (left > right)


{


volume = left;


balance = (volume > 0) ? -(1 - (right / (
float) left)) : 0;


}



else


{


volume = right;


balance = (volume > 0) ? (1 - (left / (
float) right)) : 0;


}


}



if (volume >= 0)



this.tBarArray[(
int) mixerType][i].Value = volume;



else



this.tBarArray[(
int) mixerType][i].Enabled =
false;



this.tBarArray[(
int) mixerType][i].ValueChanged +=
new System.EventHandler(
this.tBar_ValueChanged);



this.Controls.Add(
this.tBarArray[(
int) mixerType][i]);



//TrackBar Balance Creation



this.tBarBalanceArray[(
int) mixerType][i] =
new System.Windows.Forms.TrackBar();



this.tBarBalanceArray[(
int) mixerType][i].AutoSize =
false;



this.tBarBalanceArray[(
int) mixerType][i].Location =
new System.Drawing.Point(i * 60, 85 + (
int) mixerType * 225);



this.tBarBalanceArray[(
int) mixerType][i].Maximum = 320;



this.tBarBalanceArray[(
int) mixerType][i].Minimum = -320;



this.tBarBalanceArray[(
int) mixerType][i].Name = "tBarBalanceArray" + ((
int) mixerType).ToString() + i.ToString();



this.tBarBalanceArray[(
int) mixerType][i].Size =
new System.Drawing.Size(60, 30);



this.tBarBalanceArray[(
int) mixerType][i].TickFrequency = 320;



this.tBarBalanceArray[(
int) mixerType][i].TabIndex = i;



this.tBarBalanceArray[(
int) mixerType][i].SmallChange = 10;



this.tBarBalanceArray[(
int) mixerType][i].LargeChange = 50;



this.tBarBalanceArray[(
int) mixerType][i].Tag = line;



//MONO OR MORE THAN 2 CHANNELS, then let disable balance



if (lines[i].Channels != 2)



this.tBarBalanceArray[(
int) mixerType][i].Enabled =
false;



else



this.tBarBalanceArray[(
int) mixerType][i].Value = (
int) (
this.tBarBalanceArray[(
int) mixerType][i].Maximum * balance);



this.tBarBalanceArray[(
int) mixerType][i].ValueChanged +=
new System.EventHandler(
this.tBarBalance_ValueChanged);



this.Controls.Add(
this.tBarBalanceArray[(
int) mixerType][i]);



//Label Creation



this.lblArray[(
int) mixerType][i] =
new System.Windows.Forms.Label();



this.lblArray[(
int) mixerType][i].Location =
new System.Drawing.Point(i * 60, 60 + (
int) mixerType * 225);



this.lblArray[(
int) mixerType][i].Name = "lblArray" + ((
int) mixerType).ToString() + i.ToString();



this.lblArray[(
int) mixerType][i].Size =
new System.Drawing.Size(65, 26);



this.lblArray[(
int) mixerType][i].TabIndex = 10;



this.lblArray[(
int) mixerType][i].TextAlign = System.Drawing.ContentAlignment.BottomCenter;



this.lblArray[(
int) mixerType][i].Text = line.Name;



this.Controls.Add(
this.lblArray[(
int) mixerType][i]);



//CheckBox Creation



this.chkBoxArray[(
int) mixerType][i] =
new System.Windows.Forms.CheckBox();



this.chkBoxArray[(
int) mixerType][i].Location =
new System.Drawing.Point(i * 60 + 10, 225 + (
int) mixerType * 225);



this.chkBoxArray[(
int) mixerType][i].Name = "chkMuteSelect" + ((
int) mixerType).ToString() + i.ToString();



this.chkBoxArray[(
int) mixerType][i].Size =
new System.Drawing.Size(60, 16);



this.chkBoxArray[(
int) mixerType][i].Enabled =
false;



this.chkBoxArray[(
int) mixerType][i].TabIndex = 10;



this.chkBoxArray[(
int) mixerType][i].Tag = line;



if (mixerType == MixerType.Recording)


{



this.chkBoxArray[(
int) mixerType][i].Text = "Select";



if (line.ContainsSelected)


{



this.chkBoxArray[(
int) mixerType][i].Enabled =
true;



this.chkBoxArray[(
int) mixerType][i].Checked = line.Selected;


}


}



else


{



this.chkBoxArray[(
int) mixerType][i].Text = "Mute";



if (line.ContainsMute)


{



this.chkBoxArray[(
int) mixerType][i].Enabled =
true;



this.chkBoxArray[(
int) mixerType][i].Checked = line.Mute;


}


}



this.chkBoxArray[(
int) mixerType][i].CheckedChanged +=
new EventHandler(Form1_CheckedChanged);



this.Controls.Add(
this.chkBoxArray[(
int) mixerType][i]);


}


}
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
24 févr. 2006 à 11:38
Oui, mais tu n'expliques pas clairement ce que tu veux faire.
Parce que tu parles de "recuperer", mais tu entends quoi par "recuperer" ? Parce que la, tu les as tes controles, d'ailleurs tu y accedes et tu les ajoutes dans ta form...



Mx
MVP C#
0
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014
24 févr. 2006 à 12:15
oui bon voila mais contrôle son la ,j'avais mal relu mon code parce qu'il date de 2 mois excuse ,mais ce qui ce passe c'est que j'aimerai qu'il s'affiche dans un panel au lieu dans ma Form
0
mattiussi Messages postés 51 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 11 novembre 2014
24 févr. 2006 à 13:07
ok merci sa fonctionne je te remercie @+
0
Rejoignez-nous