Rapport entre TextBox et Calendar
Bonjour,
Mon apli est constituer d'une TextBox ou quand on rentre un chiffre et que l'on valide, ça affiche autant de TextBox que le nombre renter...
...elle est aussi constituer d'un calendar.
Ceq ue j'aimerais faire c'est que quand l'utilisateur selectionne une semaine sur le calendar alors les TextBox ce remette a leur forme Text initiale c'est a dire "Heure n°1"...
Voila le code que j'utilise pour affiche mes TextBox :
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 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
| protected void nbheureTextBox_TextChanged(object sender, EventArgs e)
{
Debug.WriteLine( "TextBox1_TextChanged ######" );
this.RemoveTextBox( m_kIColTxBx );
try
{
int iNbtxtBx;
if ( Int32.TryParse( ( (TextBox)( sender ) ).Text, out iNbtxtBx ) )
{
m_kIColTxBx.Clear();
for ( int i = 0; i < iNbtxtBx; ++i )
{
TextBox kTxBx = new TextBox();
kTxBx.ID = "TextBox_" + i.ToString();
kTxBx.Text = "Heure n° " + i.ToString();
kTxBx.Height = 30;
kTxBx.Width = 500;
kTxBx.Visible = true;
kTxBx.Enabled = true;
kTxBx.AutoPostBack = true;
m_kIColTxBx.Add( kTxBx );
}
AddTextBox( m_kIColTxBx );
}
}
catch ( Exception exc )
{
Debug.WriteLine( "ERROR : " + exc );
}
}
protected void TextBoxPhrase_TextChanged(object sender, EventArgs e)
{
Debug.WriteLine(" ###### TextBoxPhrase_TextChanged");
this.RemoveTextBox(m_kIColTxBx);
TextBox kTxBx = ((TextBox)(sender));
int iStart = m_kIColTxBx.IndexOf(kTxBx);
for (int i = iStart; i < m_kIColTxBx.Count; ++i)
{
m_kIColTxBx[i].Text = kTxBx.Text;
}
AddTextBox(m_kIColTxBx);
}
protected void AddTextBox(IList<TextBox> TextBoxList)
{
IEnumerator kEnumerator = TextBoxList.GetEnumerator();
TextBox kTxBx;
while (kEnumerator.MoveNext())
{
kTxBx = ((TextBox)(kEnumerator.Current));
kTxBx.TextChanged += new EventHandler(this.TextBoxPhrase_TextChanged);
this.form1.Controls.Add(kTxBx);
}
}
protected void RemoveTextBox(IList<TextBox> TextBoxList)
{
IEnumerator kEnumerator = TextBoxList.GetEnumerator();
while (kEnumerator.MoveNext())
{
this.form1.Controls.Remove(((TextBox)(kEnumerator.Current)));
}
} |
Les puristes aurons remarqué qu'il y a aussi une fonction qui permet d'écrire dans les TextBox suivant la 1ére le méme text que le text entré dans celle-ci...(merci chubyone)
Est-ce possible a faire ? et si oui par "quoi" faut-il passer ?
Merci :D