Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>do this if your usercontrol is made from VB.NET, have to handle the event and re-raise it to consumer of your control:</p> <pre><code>Public Class FilterBox &lt;Browsable(True)&gt; _ Public Shadows Event TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged RaiseEvent TextChanged(sender, e) End Sub End Class </code></pre> <p>do this if your usercontrol is made from C#, just redirect the TextChanged event of your usercontrol's textbox:</p> <pre><code>using System; using System.ComponentModel; using System.Windows.Forms; namespace Craft { public partial class FilterBox : UserControl { public FilterBox() { InitializeComponent(); } [Browsable(true)] public new event EventHandler TextChanged { add { textBox1.TextChanged += value; } remove { textBox1.TextChanged -= value; } }//TextChanged "surfacer" :-) }//FilterBox }//Craft </code></pre> <p>consuming-wise, VB.NET's FilterBox and C#'s Filterbox are the same. but the implementation in C# is more straightforward, it just plug the event of consumer programmer directly to usercontrol's textbox1's event. </p> <p>i think the title of the article <a href="http://www.informit.com/articles/article.aspx?p=31535" rel="nofollow noreferrer">Defining Add and Remove Accessor Methods for Events in VB.NET</a> should be: <strong>Want to be the envy of all your VB friends</strong>? </p> <p>as you can see from the implementation code above, C# has less runtime overhead.</p> <p>the C# code above is not possible in VB.NET: <a href="http://www.developer.com/net/net/article.php/2172721/Events-in-NET-Did-You-Know" rel="nofollow noreferrer">One might ask "why should I care?" Well, C# permits programmers to define their own add and remove subscription events. As a result a C# developer can extend the behavior of the add and remove subscription methods. One useful application of the add and remove handler is to surface an event on a constituent control</a></p> <p>note: to consume your usercontrol's textbox's changed event. in VS designer, click the Properties toolbox, click the event(lightning) icon, double-click the TextChanged, add the necessary logic.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload