在Windows窗体文本框中显示字符串

用户名

我有一个名为“ e.RequestMessage.Text的字符串在一个类中,我要显示的该字符串在Windows窗体的文本框中具有一个值。

我有一个包含一个在控制台中显示我的字符串的类的项目。因此,我想在Windows窗体的文本框中显示此字符串。我添加了一个Windows窗体(该类在前面运行)

我该怎么做?

using System;
using Eneter.Messaging.DataProcessing.Serializing;
using Eneter.Messaging.EndPoints.TypedMessages;
using Eneter.Messaging.MessagingSystems.MessagingSystemBase;
using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;
using Eneter.ProtoBuf;
using message.declarations;

namespace ServiceExample
{
    class Program
    {
        private static IDuplexTypedMessageReceiver<MyResponse, MyRequest> myReceiver;

        static void Main(string[] args)
        {
            // Instantiate Protocol Buffer based serializer.
            ISerializer aSerializer = new ProtoBufSerializer();

            // Create message receiver receiving 'MyRequest' and receiving 'MyResponse'.
            // The receiver will use Protocol Buffers to serialize/deserialize messages. 
            IDuplexTypedMessagesFactory aReceiverFactory = new DuplexTypedMessagesFactory(aSerializer);
            myReceiver = aReceiverFactory.CreateDuplexTypedMessageReceiver<MyResponse, MyRequest>();

            // Subscribe to handle messages.
            myReceiver.MessageReceived += OnMessageReceived;

            // Create TCP messaging.
            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();

            IDuplexInputChannel anInputChannel
                = aMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:8060/");

            // Attach the input channel and start to listen to messages.
            myReceiver.AttachDuplexInputChannel(anInputChannel);

            Console.WriteLine("The service is running. To stop press enter.");
            Console.ReadLine();

            // Detach the input channel and stop listening.
            // It releases the thread listening to messages.
            myReceiver.DetachDuplexInputChannel();
        }

        // It is called when a message is received.
        private static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs<MyRequest> e)
        {
            Console.WriteLine("Received: " + **e.RequestMessage.Text**);

            // Create the response message.
            MyResponse aResponse = new MyResponse();
            aResponse.Length = e.RequestMessage.Text.Length;

            // Send the response message back to the client.
            myReceiver.SendResponseMessage(e.ResponseReceiverId, aResponse);
        }
    }
}

Windows表单代码:

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

namespace ServiceExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
法赫姆·阿夫扎尔(Faheem Afzal)
private void button1_Click(object sender, EventArgs e)
    {
        sum = x + y;
        MessageBox.Show("Ans=" + sum);
    }

    private void textBox3_TextChanged(object sender, EventArgs e)
    {
        string myString = sum.ToString();
        textBox3.Text = myString;
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

裁剪字符串的最后N行以在用户窗体文本框中显示

来自分类Dev

在文本框中显示连接的字符串

来自分类Dev

在文本框中显示字符串变量

来自分类Dev

在文本框中显示连接的字符串

来自分类Dev

从文本框中读取sql字符串并在datagridview中显示

来自分类Dev

在文本框中显示字节数组,而不转换为可读的字符串

来自分类Dev

方法更改的字符串值未显示在数据绑定的文本框中

来自分类Dev

ASP.NET MVC5在文本框中显示字符串

来自分类Dev

使用按钮选择列表框项目以在文本框中显示文本字符串时

来自分类Dev

仅从文本框中的字符串打印元音

来自分类Dev

Winform在文本框中拆分字符串

来自分类Dev

+ =符号在字符串和文本框中的区别

来自分类Dev

如何从文本框中获取字符串

来自分类Dev

在用户窗体文本框中突出显示文本

来自分类Dev

突出显示用户窗体文本框中的文本

来自分类Dev

Windows窗体:文本框必须显示变量的值

来自分类Dev

如何在C#中的有序列表中显示文本框中输入的字符串?

来自分类Dev

从文本框中获取字符串并应用于字符串属性

来自分类Dev

查找字符串中单词的所有实例,并将其显示在文本框中(vb.net)

来自分类Dev

json函数返回字符串值未在mvc中的jquery中使用onchange事件显示在文本框中

来自分类Dev

Windows窗体文本框文本对齐

来自分类Dev

AngularJS过滤器显示的记录不包含过滤器文本框中的字符串

来自分类Dev

将文本框字符串拆分为数组并按数组索引 C# 显示在标签中

来自分类Dev

如何在文本框中显示 JSON 条目并在单击按钮时在字符串中移动?

来自分类Dev

清除Windows窗体中除特殊文本框外的所有文本框

来自分类Dev

将字符串从viewcontroller1传输到viewcontroller2并在uiwebview的文本框中显示条形码扫描(字符串)

来自分类Dev

在两行列表框中从文本框中添加相同的字符串?

来自分类Dev

Windows窗体文本框Enter键

来自分类Dev

从 Windows 窗体捕获文本框值

Related 相关文章

  1. 1

    裁剪字符串的最后N行以在用户窗体文本框中显示

  2. 2

    在文本框中显示连接的字符串

  3. 3

    在文本框中显示字符串变量

  4. 4

    在文本框中显示连接的字符串

  5. 5

    从文本框中读取sql字符串并在datagridview中显示

  6. 6

    在文本框中显示字节数组,而不转换为可读的字符串

  7. 7

    方法更改的字符串值未显示在数据绑定的文本框中

  8. 8

    ASP.NET MVC5在文本框中显示字符串

  9. 9

    使用按钮选择列表框项目以在文本框中显示文本字符串时

  10. 10

    仅从文本框中的字符串打印元音

  11. 11

    Winform在文本框中拆分字符串

  12. 12

    + =符号在字符串和文本框中的区别

  13. 13

    如何从文本框中获取字符串

  14. 14

    在用户窗体文本框中突出显示文本

  15. 15

    突出显示用户窗体文本框中的文本

  16. 16

    Windows窗体:文本框必须显示变量的值

  17. 17

    如何在C#中的有序列表中显示文本框中输入的字符串?

  18. 18

    从文本框中获取字符串并应用于字符串属性

  19. 19

    查找字符串中单词的所有实例,并将其显示在文本框中(vb.net)

  20. 20

    json函数返回字符串值未在mvc中的jquery中使用onchange事件显示在文本框中

  21. 21

    Windows窗体文本框文本对齐

  22. 22

    AngularJS过滤器显示的记录不包含过滤器文本框中的字符串

  23. 23

    将文本框字符串拆分为数组并按数组索引 C# 显示在标签中

  24. 24

    如何在文本框中显示 JSON 条目并在单击按钮时在字符串中移动?

  25. 25

    清除Windows窗体中除特殊文本框外的所有文本框

  26. 26

    将字符串从viewcontroller1传输到viewcontroller2并在uiwebview的文本框中显示条形码扫描(字符串)

  27. 27

    在两行列表框中从文本框中添加相同的字符串?

  28. 28

    Windows窗体文本框Enter键

  29. 29

    从 Windows 窗体捕获文本框值

热门标签

归档