本文介绍了c#windows窗体选项卡控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮我提供一个代码,用于显示文本框中输入的文本中的元音,文本应该以标签显示.. i使用选项卡控件放置文本框和标签我放置文本框在一个标签中并在另一个标签中标记.. 例如,如果在文本框中输入的文本是David 那么如果我在另一个标签中点击标签标签应该在标签内部显示一个msg:a,i plz帮我解释代码
can any one help me with a code for displaying vowels from a text entered in a textbox and text should be displayed in a lable .. i used tab control for placing textbox and lable i place textbox in one tab and lable in another.. Ex if the text entered in text box is David then if i click lable in another tab a msg should be displayed inside the lable Vowels are : a,i plz help me with the code
推荐答案使用keypress事件用于更新标签的文本框。 use keypress event for textbox to update the label.
在.cs页面上写下此方法 Write this method on your .cs page public static string ExtractVowels(string text) { // Note that this won't find upper-case vowels... var vowelArray = text.Where(c => "aeiou".Contains(c)) .ToArray(); // Upper-case it if you want, of course. return new string(vowelArray); }
在按钮上调用此方法单击
call this method on Button click
label1.Text=ExtractVowels(textbox1.text);谢谢&注意 Sham:)
Thanks & Regard Sham :)
Char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u' }; string str = textBox1.Text; string result = ""; string r = ""; char[] ch = str.ToCharArray(); foreach (char c in ch) { if (vowels.Contains(c)) { result = c.ToString(); r = r + result; } else { //consonant } label2.Text = radioButton2.Text + textBox1.Text + "Length is:" + textBox1.TextLength + "Vowels are : " + r;
更多推荐
c#windows窗体选项卡控件
发布评论