Component Compound in C # does not show all attributes

0

I have a system in which I use a dataGridView to list the fields of a table with the property dataSource , and a textBox so that the written text serves as a filter (when I type something in textBox , use the text typed to filter my table and update on dataSource of dataGridView ).

I'm learning C # and I saw that in Visual Studio, I can create a Composite Component and wanted to create a component by joining the textBox and the dataGridView .

I started the creation with a dataGridView and a textBox and generated the new component ( textBoxGrid ).

I added the new component ( textBoxGrid ) to my form and when I went to look for the dataSource property in the new component, it is not shown.

How do I make it visible?

    
asked by anonymous 15.12.2016 / 20:04

1 answer

4

You should create a "link" between the ownership of your datagridview and its component.

Something similar to this:

In your component just create a property with get , and set pointing to the property of datagridview :

If you need to set DataSource in design mode, you must add the attributes in the property.

[AttributeProvider(typeof(IListSource)), DefaultValue(null), RefreshProperties(RefreshProperties.Repaint)]
public Object DataSource
{
    get { return datagridview1.DataSource; }
    set { datagridview1.DataSource = value; }
}

See with the attribute in the property, datasource is "unlocked"

Remember that every time you change the component you should give build to the project again to upgrade.

    
15.12.2016 / 20:13