简体   繁体   English

使用System.Windows.Form不为灰色

[英]Using System.Windows.Form not greyed

I've created a windows form called Grades and when I click the Submit button, it displays the "System.Windows.Form" onto the label and then the text I've entered onto the textbox. 我创建了一个名为“成绩”的Windows窗体,当我单击“提交”按钮时,它将在标签上显示“ System.Windows.Form”,然后将我输入的文本显示在文本框中。 For example, it displays "System.Windows.Form Tom". 例如,它显示“ System.Windows.Form Tom”。 Now I've been researching online and people say that I should add it as a reference. 现在我一直在进行在线研究,人们说我应该添加它作为参考。 I already did that and it seems as though that the using statement isn't greyed in like the other using statements. 我已经做到了,好像using语句没有像其他using语句一样呈灰色。 Please Help! 请帮忙!

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

namespace Grades
{
     public partial class frmGrades : Form
     {
        public frmGrades()
        {
            InitializeComponent();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
           lblDisplayStudentName.Text = Convert.ToString(txtBoxStudentName);
           lblDisplayMessage.Text = Convert.ToString(txtBoxStudentGrade);
        }
    }
}

You need to get the text property of the textbox : 您需要获取文本框的text属性:

lblDisplayStudentName.Text = txtBoxStudentName.Text;
lblDisplayMessage.Text = txtBoxStudentGrade.Text;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 非Windows OS上的.NET Framework System.Windows.Form - .NET framework System.Windows.Form on non Windows OS 是否可以向Xamarin项目添加System.windows.form引用? - Is it possible to add a System.windows.form reference to a Xamarin project? ASP NET C#System.Windows.Form在类或名称空间“ System”中不存在 - ASP NET C# System.Windows.Form does not exist in the class or namespace 'System' 在单元测试项目中引用System.Windows.Form是一种不好的做法吗? - Is it a bad practice to reference System.Windows.Form in your Unit Test project? 如何从其 Win32 句柄中获取 System.Windows.Form 实例? - How do I get a System.Windows.Form instance from its Win32 handle? 在 Windows 系统上使用 Path.Combine() 形成 Linux 路径 - Using Path.Combine() to form a Linux path on a Windows system 使用Unity Framework,注入System.Windows.Forms.Form页面 - Using Unity Framework, inject into System.Windows.Forms.Form page 禁用的MenuItem在Windows 7上不显示灰色 - Disabled MenuItem is not greyed out on Windows 7 C#。当 Windows 表格变灰时,如何将其拖放到表格适配器中? - C#. How do I drag and drop table adapter to Windows Form when it is Greyed Out? 使用系统Windows窗体的日历控件日历C#Windows窗体 - Calendar control using System Windows Forms Calendar C# Windows form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM