MaClasse maClasse = new MaClasse(richTextBox);
public class MaClasse { public MaClasse(RichTextBox rTBox) { for (int i = 0; i < 20; i++) { rTBox.Text += "ligne" + i + "\n"; } } }
for (int i = 0; i < 1000; i++) { rTBox.Text += "ligne" + i + "\n"; rTBox.Refresh(); // Auto Scroll rTBox.Focus(); // Donne le focus au control rTBox.SelectionLength = 0; // Aucun caractère n'est sélectionné // Place le curseur à la dernière ligne : rTBox.SelectionStart = (rTBox.Text.Length - 1); // Scroll automatiquement selon la position du curseur //rTBox.ScrollToCaret(); // ça fonctionne pas très bien avec... System.Threading.Thread.Sleep(100); }
richTextBox1.Text += "ligne" + i + "\n";
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionnamespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Class1 maClasse = new Class1(richTextBox); } } }
private void InitializeComponent() { this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(98, 64); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(217, 96); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(437, 266); this.Controls.Add(this.richTextBox1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } //... private System.Windows.Forms.RichTextBox richTextBox1;
System.Windows.Forms.RichTextBox richTextBox1 = new System.Windows.Forms.RichTextBox(); this.Controls.Add(richTextBox1);
public class Class1 { public Class1(RichTextBox rTBox) { for (int i = 0; i < 20; i++) { rTBox.Text += "ligne" + i + "\n"; rTBox.Refresh(); // Rafraîchissement du textbox System.Threading.Thread.Sleep(1000); // pause de 1000ms = 1s } } }