View Full Version : شناسایی کلمه اخر تایپ شده در textbox
saeedhushmand
شنبه 03 تیر 1391, 14:17 عصر
دوستان چه جوری می شه کلمه اخری که در textbox تایپ شده رو شناسایی و پاک کرد
modern_amin
شنبه 03 تیر 1391, 14:21 عصر
میتونی اندازه متنش رو بفهمی چندتاست و بعد ایندکس مورد نظر متن رو بخونی
modern_amin
شنبه 03 تیر 1391, 14:22 عصر
در ضمن اگه مستقیم داری از sql میخونی و میندازی تو textbox
تو همون sql دستوراتی هست که اینکارو کنه
uniqueboy_ara
شنبه 03 تیر 1391, 14:55 عصر
به همین سادگی:
int len = textBox1.Text.Length;
if (len > 0)
{
textBox1.Text = textBox1.Text.Substring(0, len - 1);
}
sinaprog
شنبه 03 تیر 1391, 14:57 عصر
سلام فکر کنم textbox رو نسبت به space split کنی
string
[] a = textBox1.Text.Split(' ');
string b = a[a.Length - 1];
sinaprog
شنبه 03 تیر 1391, 15:00 عصر
به همین سادگی:
int len = textBox1.Text.Length;
if (len > 0)
{
textBox1.Text = textBox1.Text.Substring(0, len - 1);
}
این کد فقط کاراکتر آخرو حذف میکنه ؟؟؟
saeedhushmand
شنبه 03 تیر 1391, 15:08 عصر
دوستان این کد درسته
string s = textBox1.Text;
string[] words = s.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
for (i = 0; i < words.Length; i++)
{
if (words[i] != "||||" && words[i] != "|||")
{
textBox1.Invoke(new Action(() =>
{
int numberOfAttempt = 0;
Selection:
textBox1.Select(selectionStart, words[i].Length);
textBox1.ScrollToCaret();
if (textBox1.SelectedText.Length > 2 && words[i].Length > 2)
{
if (textBox1.SelectedText.Substring(0, 2) != words[i].Substring(0, 2))
{
if (numberOfAttempt <= 10 && i + numberOfAttempt < words.Length)
{
selectionStart++;
numberOfAttempt++;
goto Selection;
}
else
{
selectionStart -= numberOfAttempt;
}
}
}
selectionStart += textBox1.SelectedText.Length;
}));
}
else
selectionStart++;
}
}
uniqueboy_ara
شنبه 03 تیر 1391, 15:13 عصر
این کد فقط کاراکتر آخرو حذف میکنه ؟؟؟
دقیقا!
از کاراکتر اول تا یکی مونده به آخر رو جدا میکنه و داخل TextBox مادر میریزه
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.