Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何创建与textbox setvalue方法的签名匹配的委托?_C#_Winforms_Textbox_Delegates - Fatal编程技术网

C# 如何创建与textbox setvalue方法的签名匹配的委托?

C# 如何创建与textbox setvalue方法的签名匹配的委托?,c#,winforms,textbox,delegates,C#,Winforms,Textbox,Delegates,我有一个wpf应用程序,其中我使用以下代码: //Create a Delegate that matches the Signature of the TextBox SetValue method private delegate void UpdateSylvacDelegate(System.Windows.DependencyProperty dp, Object value); private void Process() { var

我有一个wpf应用程序,其中我使用以下代码:

    //Create a Delegate that matches the Signature of the TextBox SetValue method
    private delegate void UpdateSylvacDelegate(System.Windows.DependencyProperty dp, Object value);

    private void Process()
    {
        var settings = new Settings();
        string value;

        //Create a new instance of our TextBox Delegate that points to the TextBox SetValue method.
        var updateTextBoxDelegate = new UpdateSylvacDelegate(textBox_Result.SetValue);
       ...
       ...
现在,我想使用在新的windows窗体应用程序中截取的相同代码,同时使用textbox textbox_结果。由于某些原因,当我尝试创建新实例时,windows窗体中的textBox\u结果没有可用的SetValue方法

 var updateTextBoxDelegate = new UpdateSylvacDelegate(textBox_Result.???); <-- SetValue not exists here!

原因是什么?如何解决此问题?

依赖项属性适用于WPF和Silverlight。你的问题被标记为winforms-你实际使用的是什么类型的textbox?@JonSkeet一个简单的win forms textBoxRight,因此你没有依赖属性,所以你不应该在任何地方引用它们。正如Jon指出的,你使用的textbox类来自winforms,而具有SetValue方法的textbox类来自WPF。不能将WPF类与Winforms一起使用。基于非常稀疏的代码示例,您似乎希望以后能够以抽象的方式在TextBox对象中设置属性。根据具体的场景,这应该是可能的,但没有关于如何调用updateTextBoxDelegate实例的明确细节,包括这是处理一个属性还是多个属性,无法回答。请参阅和