您可以在下面解释此代码吗? [英] Can you explain this code below?

查看:76
本文介绍了您可以在下面解释此代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我不明白下面的代码.您想向我解释一下吗?
这是代码:

Dear all,

I do not understand the code below. Would you like to explain me about it?
Here is the code:

private void txtFirstName_Enter(object sender, EventArgs e)
        {
            TextBox txt = (TextBox)sender;
            string t = txt.Name.Substring(3, txt.Name.Length - 3);
            if (txt.Text.ToLower() == t.ToLower())
            {
                txt.ForeColor = System.Drawing.Color.Black;
                txt.Text = "";
            }
        }

        private void txtFirstName_leave(object sender, EventArgs e)
        {
            TextBox txt = (TextBox)sender;
            string t = txt.Name.Substring(3, txt.Name.Length - 3);
            if (txt.Text.ToLower() == t.ToLower() || txt.Text == "")
            {
                txt.ForeColor = System.Drawing.Color.Silver;
                txt.Text = t;

            }
            else
            {
                txt.ForeColor = System.Drawing.Color.Black;
            }
        }



非常感谢.



Thank you so much.

推荐答案

string t = txt.Name.Substring(3, txt.Name.Length - 3);



阅读文档不难理解
http://msdn.microsoft.com/en-us/library/aka44szs.aspx [ ^ ]



Not difficult to understand if you read the documentation
http://msdn.microsoft.com/en-us/library/aka44szs.aspx[^]


这篇关于您可以在下面解释此代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆