首先创建两个窗体,在窗体1和窗体2放上对应的控件
在窗体1的代码如下
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 委托改变控件值
{
public delegate void MyDel();
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public static MyDel myDel;//定义一个委托类型的变量
public static string str;//定义一个静态类型的字段
public Form1()
{
InitializeComponent();
myDel = new MyDel(Change);
}
/// <summary>
/// 更改值
/// </summary>
public void Change()