查询.net控件中的属性 [英] Query about properties in .net control

查看:55
本文介绍了查询.net控件中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家,



我们把任何控件放在桌子布局面板的单元格内

它包括像Col,Row,RowSpan这样的属性,ColSpan到那个控件



这样的许多控件包括表格上其他控件的额外属性

例如错误提供程序,工具提示,表格布局面板等。



我想知道如何为自己的控件创建此逻辑?

因此,当我将自定义组件粘贴到表单上时,它会在该表单上的其他控件中包含一些额外属性



谢谢:)

Hello experts,

When we put any control inside cell of table layout panel
It includes properties like Col,Row,RowSpan,ColSpan to that control

many controls like this that include extra properties to other controls on form
e.g. Error provider, Tool tip, table layout panel etc.

I want to know how I can create this logic for my own control?
so that when I paste my custom component on form it include some extra properties to other controls on that form

thanks :)

推荐答案

这是最终的解决方案:



Here is the final solution:

  1. 请在问题的评论中宣读讨论。我认为你拥有所需的一切。
  2. 最后尝试一下!你在浪费太多时间去问问题。当你尝试更清晰,更快速地创建一些自定义控件时,你会发现它是如何工作的。
  1. Please read out discussion in the comments to the question. I think you have everything you need.
  2. Try it all, at last! You are wasting too much time on asking. You will find out how it all works when you try to create some custom control much clearly and even much faster.









这只是一个猜测:也许你找不到一种方法来将你的控件的属性绑定到子控件属性。这可以给你一个想法:







This is just a guess: maybe you cannot find a way to bind your control''s property with a child control property. This can give you the idea:

public partial class MyControl { // base class can be in other part

    TextBox MyTextBox = new TextBox();

    //...

    public string MyTextBoxText {
        get { return MyTextBox.Text; }
        set {
            if (value == MyTextBox.Text) return;
            MyTextBox.Text = value;
        }
    }

}





这样,你不会暴露孩子(这将是适当的封装),但只暴露你需要的属性。设计师也会选择它们。



更多的问题是暴露那些内部事件。你能知道怎么做吗?这是纯粹的想法,除了理解属性和事件实例如何工作之外没有其他秘密。



-SA

这篇关于查询.net控件中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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