C# ProgressBar ve textbox Kullanımı - Bilişim Konuları

C# ProgressBar ve textbox Kullanımı

Bu örneğimizde c# programında ProgressBar nesnesinin kullanımıyla ilgili bir program yaptık. Program textbox nesnesine girilen karakter sayılarını sayarak ona göre progressbar nesnesinin ne kadar dolması gerektiğini otomatik olarak hesaplayıp uyguluyor. Textbox nesnesinin mode özelliğini multiline ayarladık. Textbox nesnesinin textchange özelliğine progressbar nesnesini bağlayarak her karakter girildiğinde otomatik olarak hesaplama yapıp sonucu progressbar nesnesine uyguluyor.

Programın c# görüntüleri:

progressbar1

progressbar1

progressbar2

progressbar2

Programın C# kodları:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace prograssbarornek2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
textBox1.MaxLength = 50;
progressBar1.Maximum = 100;
progressBar1.Minimum = 0;

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
int u = textBox1.TextLength;
int d = u * 100 / textBox1.MaxLength;
progressBar1.Value = d;
label1.Text = textBox1.TextLength.ToString();
label2.Text = "%" + progressBar1.Value;
}
}
}
Bu Yazıya Tepkin Nedir?
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
3

Yorum Yap