我想计算text_content 中输入内容的 字符的长度 就是字节:一个汉字是两个字节 一个字母是一个字节 数字也是一个字节
在窗体中已经有64个button 每个button代表一个64个字节想实现的是:输入的内容若为空 没有按钮变绿
若有输入 则有一个bottom变绿
输入内容大小超过64B 则再亮一个botton
若删除字符 相应的按钮颜色也根据大小变化 private void text_content_TextChanged(object sender, EventArgs e)
{
int count=Encoding.Unicode.GetByteCount(text_content.Text)/ 64;
Convert.ToInt32( textBox_charnumber.Text =count);//如何在textBox_charnumber.Text 显示输入内容的字节大小?
for (int i = 0; i < count; i++)
{
btn[i].BackColor = Color.Green;
}
}
在窗体中已经有64个button 每个button代表一个64个字节想实现的是:输入的内容若为空 没有按钮变绿
若有输入 则有一个bottom变绿
输入内容大小超过64B 则再亮一个botton
若删除字符 相应的按钮颜色也根据大小变化 private void text_content_TextChanged(object sender, EventArgs e)
{
int count=Encoding.Unicode.GetByteCount(text_content.Text)/ 64;
Convert.ToInt32( textBox_charnumber.Text =count);//如何在textBox_charnumber.Text 显示输入内容的字节大小?
for (int i = 0; i < count; i++)
{
btn[i].BackColor = Color.Green;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货