<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>textbox Archive - Robert Skibbe</title>
	<atom:link href="https://robbelroot.de/blog/tag/textbox/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>alias RobbelRoot – Freelance Full Stack Developer .NET</description>
	<lastBuildDate>Sun, 12 Nov 2023 12:46:41 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://robbelroot.de/wp-content/uploads/2020/12/cropped-favicon-32x32.png</url>
	<title>textbox Archive - Robert Skibbe</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to debounce function calls in .NET with on-board resources</title>
		<link>https://robbelroot.de/blog/how-to-debounce-function-calls-in-net-with-on-board-resources/</link>
					<comments>https://robbelroot.de/blog/how-to-debounce-function-calls-in-net-with-on-board-resources/#respond</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sun, 12 Nov 2023 12:02:54 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C# HowTo's]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic .NET (EN)]]></category>
		<category><![CDATA[Visual Basic .NET troubleshooting]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[calls]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[debounce]]></category>
		<category><![CDATA[debouncing]]></category>
		<category><![CDATA[delay]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[propertychanged]]></category>
		<category><![CDATA[reactive]]></category>
		<category><![CDATA[subject]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[throttling]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[visual basic]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=17943</guid>

					<description><![CDATA[<p>The easiest way to debounce function calls in C# &#38; VB.NET is by simply using the &#8222;Subject&#8220; class from the &#8222;System.Reactive.Subjects&#8220; namespace. Create an instance of this class, register a &#8222;callback&#8220; and provide the values by calling the &#8222;OnNext&#8220; method. This way you don&#8217;t need to install external or third-party &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/how-to-debounce-function-calls-in-net-with-on-board-resources/">How to debounce function calls in .NET with on-board resources</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/How-to-debounce-function-calls-in-.NET-with-on-board-resources-for-csharp-and-VB.NET_.png"><img fetchpriority="high" decoding="async" width="659" height="371" src="https://robbelroot.de/wp-content/uploads/2023/11/How-to-debounce-function-calls-in-.NET-with-on-board-resources-for-csharp-and-VB.NET_.png" alt="How to debounce function calls in .NET with on-board resources for C# and VB.NET" class="wp-image-17947" title="How to debounce function calls in .NET with on-board resources for C# and VB.NET"/></a><figcaption class="wp-element-caption">How to debounce function calls in .NET with on-board resources for C# and VB.NET</figcaption></figure>



<p><strong>The easiest way to debounce function calls in C# &amp; VB.NET is by simply using the &#8222;Subject&#8220; class from the &#8222;System.Reactive.Subjects&#8220; namespace. Create an instance of this class, register a &#8222;callback&#8220; and provide the values by calling the &#8222;OnNext&#8220; method. This way you don&#8217;t need to install external or third-party libraries.</strong></p>






<h2 class="wp-block-heading">Without debouncing methods in C# or VB.NET – a visual example</h2>



<p>Do you know these typical situations where your impatient application user is like bombing your controls with inputs – therefore triggering functions? I think every .NET developer will encounter this kind of situation at some point in time. Let&#8217;s see in today&#8217;s blogpost how we can actually handle these situations without external / third-party tools.</p>


<p class="rr-alert info" style="background:#e3f7fc;"><img decoding="async" alt="Info notice" src="https://robbelroot.de/wp-content/themes/pinboard-child/imgs/info.png"><span style="color:black;align-self: center;">In a hurry? Go to the <a href="#Quick-example">quick examples section</a>, if you just need some code. Look at <a href="#Using-the-Subject-class-for-debouncing">the detailed explanation</a>, if you need more in-depth information. However make sure, that you understand the stuff behind the scenes :)!</span></p>



<p>Maybe one of these situations <strong>look like the following image</strong>, keep an eye on the output window of Visual Studio as well. Please don&#8217;t get confused, as this is an image from my custom CRM software being translated to german. I added some english test projects for this image though:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-.NET-without-debouncing-function-calls.gif"><img decoding="async" width="773" height="429" src="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-.NET-without-debouncing-function-calls.gif" alt="Demonstrating input spam in .NET without debouncing function calls" class="wp-image-17953" title="Demonstrating input spam in .NET without debouncing function calls"/></a><figcaption class="wp-element-caption">Demonstrating input spam in .NET without debouncing function calls</figcaption></figure>



<p>As you can see, <strong>each time you&#8217;re typing a letter</strong> into the textbox, you <strong>will trigger the corresponding function</strong>. With the average typing speed of a user, being between 190 and 200 characters per minute (CPM), this is <strong>very very bad</strong>! A more experienced or like professional writer could even achieve up to twice the amount of words / characters.</p>



<p>Usually we would <strong>wish for something like the image below</strong> – being the result of this blogpost:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-C-with-debouncing-function-calls-1.gif"><img decoding="async" width="773" height="429" src="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-C-with-debouncing-function-calls-1.gif" alt="The end result with debounced calls" class="wp-image-18023" title="The end result with debounced calls"/></a><figcaption class="wp-element-caption">The end result with debounced calls</figcaption></figure>



<p>I mean, the example in the image is very typical and actually <strong>no &#8222;wrong use&#8220; of the</strong> application&#8217;s user himself. This is exactly where <strong>we</strong> – being developers – <strong>should come into play</strong>. It&#8217;s our job to react to the users input speed and adjust &#8222;behind the scenes stuff&#8220; – accordingly!</p>



<h2 class="wp-block-heading">An on-board resource to debounce function calls</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/The-on-board-Subject-class-of-the-System.Reactive.Subjects-namespace-to-debounce-function-calls-in-.NET_.png"><img loading="lazy" decoding="async" width="659" height="371" src="https://robbelroot.de/wp-content/uploads/2023/11/The-on-board-Subject-class-of-the-System.Reactive.Subjects-namespace-to-debounce-function-calls-in-.NET_.png" alt="The on-board Subject class of the System.Reactive.Subjects namespace to debounce function calls in .NET" class="wp-image-17970" title="The on-board Subject class of the System.Reactive.Subjects namespace to debounce function calls in .NET"/></a><figcaption class="wp-element-caption">The on-board Subject class of the System.Reactive.Subjects namespace to debounce function calls in .NET</figcaption></figure>



<p>Being a developer, it&#8217;s pretty nice to just let your creativity flow and develop things from start, but not always, right? I mean, there are circumstances, where you will be thinking: &#8222;God, this is such a common task, isn&#8217;t there already some stuff for that!? I don&#8217;t want to reinvent the wheel!&#8220;. This is exactly where the &#8222;Subject&#8220; class from the <strong>&#8222;<a href="https://learn.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh211639(v=vs.103)">System.Reactive.Subjects</a>&#8222;-namespace</strong> will help!</p>



<p id="dad-explanation">The easiest way to explain the usage of the subject in our case, is like you being a dad (or of course a mom&#8230;). Imagine, that your child is asking you about eating candy over and over again. No matter how often your child will be asking (of course depending on your parenting style), your answer will probably – still – be &#8222;No, not yet!&#8220;. I mean your mini-me shouldn&#8217;t probably be allowed to eat candy, everytime he / she asks. <strong>Only if your son behaved nice and didn&#8217;t ask for a specific amount of time</strong>.</p>



<p>Now <strong>swap yourself</strong> – being the dad in the previous example – <strong>with </strong>some sort of thing, some <strong>subject</strong>! That subject will now &#8222;filter&#8220; the requests for you instead and only let &#8222;valid&#8220; ones pass through. The requests are now coming from some sort of user input, instead of being your child requesting candy.</p>



<p>Take a look at this image representing the situation explained from above:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Debouncing-multiple-input-to-one-single-function-call-in-.NET_.png"><img loading="lazy" decoding="async" width="659" height="371" src="https://robbelroot.de/wp-content/uploads/2023/11/Debouncing-multiple-input-to-one-single-function-call-in-.NET_.png" alt="Debouncing multiple input to one single function call in .NET" class="wp-image-17967" title="Debouncing multiple input to one single function call in .NET"/></a><figcaption class="wp-element-caption">Debouncing multiple input to one single function call in .NET</figcaption></figure>



<p>As you can see, there&#8217;s so much input happening (mouseclicks in this case), but the &#8222;debouncer&#8220; will only allow 1 function call. In the next section, we will take a look at actually implementing the mentioned &#8222;subject&#8220; class. Especially that &#8222;time passed after last input&#8220; is pretty important.</p>



<h2 class="wp-block-heading">Installing System.Reactive</h2>



<p>I know, I know, you&#8217;re thinking: &#8222;But Robert, you said no external libraries&#8220;, but hear me out&#8230; I mean, this stuff is coming from microsoft itself residing inside of the &#8222;System.Reactive&#8220; namespace, so &#8211; for me this isn&#8217;t &#8222;third-party&#8220;, etc. If you write the correct class name, it will even suggest you to install the package within 3 seconds – so you don&#8217;t even need like the NuGet paket manager, etc. (Of course you can use it though).</p>



<p>We will be using the easiest method to install the small package, just declare some variable or a field of the type and open the suggestions by hovering over the error and clicking &#8222;show potential fixes&#8220;. Or you can just use the hotkey &#8222;Ctrl+.&#8220;. We will be using / declaring the class in the section below, as well, so we will need it anyways!</p>



<p>Take a look at the following screenshot to install System.Reactive or go into the NuGet paket manager as usual and install it manually.</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Installing-the-System.Reactive-package-to-use-the-Subject-class.png"><img loading="lazy" decoding="async" width="859" height="473" src="https://robbelroot.de/wp-content/uploads/2023/11/Installing-the-System.Reactive-package-to-use-the-Subject-class.png" alt="Installing the System.Reactive package to use the Subject class" class="wp-image-18033" title="Installing the System.Reactive package to use the Subject class"/></a><figcaption class="wp-element-caption">Installing the System.Reactive package to use the Subject class</figcaption></figure>



<h2 class="wp-block-heading" id="using-subject-class">Using the Subject class for debouncing</h2>



<p>After we&#8217;ve discussed the basic problem and some theoretical approaches, we will now take a look at an actual usage example. When talking about debouncing, we should first take a look at some &#8222;well-known values&#8220; like: &#8222;What is a commonly used delay for debouncing?&#8220;. Searching further, you will find some values being between like 150 and 400 milliseconds.</p>



<p>As always, I would encourage you to adjust these times to your specific usecase, as these can differ from project to project and so on. In the end, we will be using 400 milliseconds for our example, as this was used by a big &#8222;library&#8220; consuming inputs, I&#8217;ve commonly used in the past. Sadly, I don&#8217;t remember the name, lol.</p>


<p class="rr-alert info" style="background:#e3f7fc;"><img decoding="async" alt="Info notice" src="https://robbelroot.de/wp-content/themes/pinboard-child/imgs/info.png"><span style="color:black;align-self: center;">Keep in mind, that your <strong>used technology</strong> (WPF or Winforms) <strong>isn&#8217;t</strong> pretty much <strong>important</strong>. You will be able to use the common &#8222;pattern&#8220; of the Subject class for both of those. Your used language (C# or VB.NET) isn&#8217;t relevant, as well. You might need to adjust the code for like using MVVM, etc. – but in general, it&#8217;s the same.</span></p>



<h3 class="wp-block-heading">Declaring and instantiating the subject class</h3>



<p>With an emphasis on the above info-box, we will now declare and instantiate an example instance of the subject. At this point, <strong>you should know the data being used</strong> for the &#8222;Subject&#8220;, as it <strong>needs a generic type parameter</strong>. If you&#8217;re trying to <strong>debounce an input string from like a textbox</strong>, your generic type would therefore be a string.</p>



<p>Take a look at this example, preparing to debounce a string input from a textbox, being in a Windows Forms (Winforms) app – again, you can easily adjust to fit your normal or MVVM WPF app as well:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="declaration-instantiation">// import the namespace for the Subject
using System.Reactive.Subjects;

// a typical Winforms "Form"
public class Form1 : Form
{

  // declare the Subject
  Subject&lt;string> _searchSubject;

  // things get typically instantiated
  // inside of the constructor
  public Form1()
  {
    _searchSubject = new Subject&lt;string>();
    _searchSubject
      .Throttle(TimeSpan.FromMilliseconds(400));
  }

}</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="declaration-instantiation">' import the namespace for the Subject
Imports System.Reactive.Subjects

' a typical Winforms "Form"
Public Class Form1

  ' declare the Subject
  Private _searchSubject As Subject(Of String)

  ' things get typically instantiated
  ' inside of the constructor
  Public Sub New()
    _searchSubject = New Subject(Of String)()
    _searchSubject _
      .Throttle(TimeSpan.FromMilliseconds(400))
  End Sub

End Class</pre>



<p>After we have declared and instantiated a subject with the correct generic type being &#8222;string&#8220; (for our usecase), we can proceed. So far, there&#8217;s like nothing happening! This is, because we are missing like two steps when using the subject class. Take a look at the next section, soon!</p>



<p>In the last part of this section, we will configure the &#8222;_searchSubject&#8220; instance, to debounce the input by 400ms. Just call the &#8222;Throttle&#8220; method with an appropriate parameter as in the example. We&#8217;re using the &#8222;TimeSpan.FromMilliseconds&#8220; helper here!</p>



<h3 class="wp-block-heading">Feeding the user input into our subject</h3>



<p>Now that we have declared and created an actual instance of the subject class, we can start feeding the actual input of the user to the subject. Remember, this would be the child asking the dad <strong><a href="#dad-explanation">in the above example</a></strong>. As the raw input will usually be coming from some sort of input controls like textboxes, we will use one of those for our typical example.</p>



<p>So the first step would be, to do something like this: &#8222;Everytime the text of the textbox changes, I will feed that information to our subject&#8220;. Basically, we need to therefore react to the user typing some input into the textbox and that&#8217;s pretty basic, right?</p>



<p>Take a look at this – you of course have to make sure, that you actually have a textbox on your form like &#8222;TextBox1&#8220;:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="feeding-user-input">public class Form1 : Form
{

  public Form1()
  {
    // the other code from above!
    TextBox1.TextChanged += TextBox1_TextChanged;
  }

  private void TextBox1_TextChanged(object? sender, EventArgs e)
  {
    // each time the user types a letter, we will get here
    // now feed the information to our subject from
    // the code from above
    _searchSubject.OnNext(TextBox1.Text);
  }

}</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="feeding-user-input">Public Class Form1

  Public Sub New()
    ' the other code from above
    ' to stay the same with the C# example
    ' you could of course use the Handles keyword...
    AddHandler TextBox1.TextChanged, AddressOf TextBox1.TextChanged
  End Sub

  Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
    ' each time the user types a letter, we will get here
    ' now feed the information to our subject from
    ' the code from above
    _searchSubject.OnNext(TextBox1.Text)
  End Sub

End Class</pre>



<h3 class="wp-block-heading">Registering a &#8222;callback&#8220;</h3>



<p>Right now, we have already created the subject instance and configured it, to have some sort of throttling process going on. We&#8217;ve also created a handler function – listening to the TextBox TextChanged event – to feed information to our subject. To make the final step, we just need to tell the subject: &#8222;Hey, this is our function you should be calling, when everything&#8217;s alright!&#8220;.</p>



<p>So let&#8217;s now tell our subject to call the specific method we want to be called – after it took out all the noise:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="registering-callback">public class Form1 : Form
{

  public Form1()
  {
    // the other code from above!
    // notice the additional "Subscribe" call
    _searchSubject
      .Throttle(TimeSpan.FromMilliseconds(400))
      .Subscribe(DebouncedSearchTextChanged);
  }

  private void DebouncedSearchTextChanged(string searchText)
  {
    // do you API stuff without the noise!
  }

}</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="registering-callback">Public Class Form1

  Public Sub New()
    ' the other code from above!
    ' notice the additional "Subscribe" call
    _searchSubject _
      .Throttle(TimeSpan.FromMilliseconds(400)) _
      .Subscribe(DebouncedSearchTextChanged)
  End Sub

  Private Sub DebouncedSearchTextChanged(searchText As String)
    ' do you API stuff without the noise!
  End Sub

End Class</pre>



<h3 class="wp-block-heading">How it looks now – being debounced!</h3>



<p>Our calls now look like the following. I&#8217;m just typing a lot of stuff and only if I stop typing with an additional delay of like 400ms – our target function will be called, great!</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-C-with-debouncing-function-calls.gif"><img loading="lazy" decoding="async" width="773" height="429" src="https://robbelroot.de/wp-content/uploads/2023/11/Demonstrating-input-spam-in-C-with-debouncing-function-calls.gif" alt="Demonstrating input spam in .NET with debouncing function calls" class="wp-image-18021" title="Demonstrating input spam in .NET with debouncing function calls"/></a><figcaption class="wp-element-caption">Demonstrating input spam in .NET with debouncing function calls</figcaption></figure>



<h2 class="wp-block-heading">Quick example</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/11/Quick-Examples-of-dynamic-control-access-in-dotnet.png"><img loading="lazy" decoding="async" width="659" height="371" src="https://robbelroot.de/wp-content/uploads/2023/11/Quick-Examples-of-dynamic-control-access-in-dotnet.png" alt="A quick example of debouncing method calls using the subject class" class="wp-image-17842" title="A quick example of debouncing method calls using the subject class"/></a><figcaption class="wp-element-caption">A quick example of debouncing method calls using the subject class</figcaption></figure>



<p>In this section, you will find pretty quick examples of the subject class usage. If you need more explanation / details, take a look at <strong><a href="#using-subject-class">the previous section</a></strong>.</p>



<p>Keep in mind, that this example can be applied to WPF and Windows Forms, but as WPF possibly implies using MVVM (or not), I thought, the Winforms example would be more typical and easier.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="quick-example">// import the namespace for the Subject
using System.Reactive.Subjects;

public class Form1 : Form
{

  // declare the Subject
  Subject&lt;string> _searchSubject;

  public Form1()
  {
    // create an instance
    _searchSubject = new Subject&lt;string>();
    // configure
    _searchSubject
      .Throttle(TimeSpan.FromMilliseconds(400))
      .Subscribe(DebouncedSearchTextChanged);
    TextBox1.TextChanged += TextBox1_TextChanged;
  }

  private void TextBox1_TextChanged(object? sender, EventArgs e)
  {
    // each time the user types a letter, we will get here
    // now feed the information to our subject
    _searchSubject.OnNext(TextBox1.Text);
  }

  private void DebouncedSearchTextChanged(string searchText)
  {
    // do you API stuff without the noise!
    System.Diagnostics.Debug.WriteLine($"Debounced: {searchText}");
  }

}</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="quick-example">' import the namespace for the Subject
Imports System.Reactive.Subjects

Public Class Form1
    Inherits Form

    ' declare the Subject
    Private _searchSubject As Subject(Of String)

    Public Sub New()
        ' create an instance
        _searchSubject = New Subject(Of String)()
        ' configure
        _searchSubject _
            .Throttle(TimeSpan.FromMilliseconds(400)) _
            .Subscribe(AddressOf DebouncedSearchTextChanged)
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As Object?, ByVal e As EventArgs) Handles TextBox1.TextChanged
        ' each time the user types a letter, we will get here
        ' now feed the information to our subject
        _searchSubject.OnNext(TextBox1.Text)
    End Sub

    Private Sub DebouncedSearchTextChanged(ByVal searchText As String)
        ' do you API stuff without the noise!
        System.Diagnostics.Debug.WriteLine($"Debounced: {searchText}")
    End Sub

End Class</pre>



<h2 class="wp-block-heading">Wrapping up – debouncing method calls</h2>



<p>In today&#8217;s blogpost, I&#8217;ve explained a common problem when working with user input. There are many situations where users will just bomb the UI by typing characters or like selecting values from a selection control. This will trigger many unwanted function calls, eventually resulting in too many API calls or performance problems.</p>



<p>We then used the &#8222;Subject&#8220;-class residing in the &#8222;System.Reactive.Subjects&#8220;-namespace to implement some sort of throttling / debouncing. Even if many inputs will be provided by the user, our &#8222;Subject&#8220; instance will take care of only triggering the target function, if a specific amount of time has passed (since the last provided input).</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/how-to-debounce-function-calls-in-net-with-on-board-resources/">How to debounce function calls in .NET with on-board resources</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/how-to-debounce-function-calls-in-net-with-on-board-resources/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>VB NET Formular automatisch ausfüllen (Winforms)</title>
		<link>https://robbelroot.de/blog/vbnet-formular-automatisch-ausfuellen-winforms/</link>
					<comments>https://robbelroot.de/blog/vbnet-formular-automatisch-ausfuellen-winforms/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Wed, 15 Dec 2021 17:40:57 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic .NET]]></category>
		<category><![CDATA[Visual Basic .NET Problemlösungen]]></category>
		<category><![CDATA[ausfüllen]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[automatisch]]></category>
		<category><![CDATA[automatisiert]]></category>
		<category><![CDATA[automatisierung]]></category>
		<category><![CDATA[complete]]></category>
		<category><![CDATA[fill]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[formular]]></category>
		<category><![CDATA[kompletieren]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[setzen]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[texte]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[vervollständigen]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=6744</guid>

					<description><![CDATA[<p>VB.NET Formulare automatisch ausfüllen! Ein VB NET Formular automatisch ausfüllen zu lassen wäre vermutlich für jeden &#8222;Windows Forms&#8220; geprägten Entwickler eine Erleichterung. Man designt die Form seiner Wahl und möchte natürlich bei Aufruf die notwendigen Daten anzeigen. Besonders beim Flow aus diversen Suchmasken heraus ist es normal, dass man eine &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbnet-formular-automatisch-ausfuellen-winforms/">VB NET Formular automatisch ausfüllen (Winforms)</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formular-automatisch-ausfuellen.png"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formular-automatisch-ausfuellen.png" alt="VB.NET Form automatisch ausfüllen" class="wp-image-6747" title="VB.NET Form automatisch ausfüllen"/></a><figcaption>VB.NET Form automatisch ausfüllen</figcaption></figure>






<h2 class="wp-block-heading">VB.NET Formulare automatisch ausfüllen!</h2>



<p>Ein <strong>VB NET Formular automatisch ausfüllen zu lassen</strong> wäre vermutlich für jeden &#8222;Windows Forms&#8220; geprägten Entwickler eine Erleichterung. Man designt die Form seiner Wahl und möchte natürlich bei Aufruf die notwendigen Daten anzeigen. Besonders beim Flow aus diversen Suchmasken heraus ist es normal, dass man eine Detail-Ansicht mit entsprechenden Daten aufruft.</p>



<h3 class="wp-block-heading">Wie es meistens ist..</h3>



<p>Am besten wäre es natürlich, wenn man dem Formular direkt sagen könnte: &#8222;Hey, die Daten findest Du dort&#8220;. Mit modernen Mitteln wie in der WPF (Windows Presentation Foundation) ist dies durch Datenbindung eine gängige und vor allem einfache Praxis.</p>



<p>Dort findet man durch die saubere Trennung zwischen GUI und Daten eine simple und direkt in XAML implementierte Möglichkeit. In den guten alten Winforms findet man jedoch seltenst (jedenfalls aus meiner Erfahrung gesprochen) datengebundene Steuerelemente.</p>



<h3 class="wp-block-heading">Monkey Work – ney, Automatisierung – yay!</h3>



<p>Dort sieht es dann entgegengesetzt jeglicher Automatisierung eher so aus:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">TextBox1.Text = "..."
TextBox2.Text = "..."
TextBox3.Text = "..."
TextBox4.Text = "..."
' ....</pre>



<p>Eventuell entwickelt man wenigstens einigermaßen sauber und wählt passende Namen für die Textboxen:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tbFirstName.Text = "..."
tbLastName.Text = "..."
tbZip.Text = "..."
tbCity.Text = "..."
' ....</pre>



<p>Schon besser, aber natürlich kann man sich schon vorstellen, dass dies nicht unbedingt das Gelbe vom Ei ist. Man wird auf diverse Probleme, bzw. Monkey-Work stoßen, Welche für Wartung und Co. nicht gerade vorteilhaft sind. Tonnenweise &#8222;duplicated Code&#8220; und schon glatt eine Qual, wenn es bei einem Objekt mit 30 Properties heißt: &#8222;Hey, zeige die Daten mal an&#8230;&#8220;.</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formulare-ausfuellen-Monkey-Work.png"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formulare-ausfuellen-Monkey-Work.png" alt="VB.NET Formulare ausfüllen Monkey Work" class="wp-image-6750" title="VB.NET Formulare ausfüllen Monkey Work"/></a><figcaption>VB.NET Formulare ausfüllen Monkey Work</figcaption></figure>



<p>Nun ist man an einem Punkt, wo die bekannte Faulheit doch zum Vorteil sein und zu mehr Effizienz beitragen kann. Wie so häufig, haben wir als Entwickler die Möglichkeit uns gewisse (und vor allem wiederkehrende Aufgaben) zu vereinfachen. Not macht erfinderisch, richtig?</p>



<h3 class="wp-block-heading">An die Zukunft denken</h3>



<p>Je nachdem wie viel Planung und anschließenden Zeitaufwand man bereit ist zu investieren (nicht opfern!), wird die bevorstehende Arbeit beeinflussen. Man sollte meiner Meinung nach jedoch immer eins im Hinterkopf behalten: &#8222;Think twice, code once&#8220;! Leider arbeiten viele Entwickler auch gerne nach dem &#8222;Copy &amp; Paste&#8220;-Prinzip, zur Not auch projektübergreifend.</p>



<p>Statt hier zukunftsorientiert zu denken, werden Aufgaben häufig nur akut und schnell gelöst. Auch wenn die Erledigung einiger Aufgaben ggf. am Anfang nervig und zeitaufwendig sind, können Sie einem später unfassbar viel Zeit ersparen. Dies gilt natürlich nicht nur für das aktuelle Projekt, sondern vermutlich auch noch für später anstehende Projekte und Problemstellungen.</p>



<h2 class="wp-block-heading">Herangehensweise – VB NET Formular automatisch ausfüllen</h2>



<p>Im nächsten Schritt machen wir uns einmal ein paar Gedanken bezüglich der Herangehensweise, die (Windows Forms)-Formulare automatisiert(er) auszufüllen. Auch wenn wir hier vermutlich noch keine volle Suite an Mini-Tools generieren werden, wird das meinerseits dargestellte Beispiel als Startschuss dienen können.</p>



<p>Jeder Entwickler im NET Bereich wird wohl immer wieder mal mit den guten alten <a href="https://docs.microsoft.com/de-de/dotnet/api/system.windows.forms.textbox?view=windowsdesktop-6.0" target="_blank" rel="noreferrer noopener"><strong>Textboxen</strong></a> zu tun haben. Ich denke, dass dieses Steuerelement daher auch die erste zu bearbeitende Anlaufstelle sein sollte. Wenn man hingegen an <a href="https://docs.microsoft.com/de-de/dotnet/api/system.windows.forms.checkbox?view=windowsdesktop-6.0" target="_blank" rel="noreferrer noopener"><strong>Checkboxen</strong></a>, <a href="https://docs.microsoft.com/de-de/dotnet/api/system.windows.forms.listbox?view=windowsdesktop-6.0" target="_blank" rel="noreferrer noopener"><strong>Listboxen</strong></a> und an die anderen Steuerelemente denkt, könnte es schon ein wenig komplexer werden.</p>



<p>Vielleicht werde ich dafür dann noch einmal einen getrennten Beitrag in Zukunft erstellen. Schauen wir einmal, wo mich die Beitrags-Reise, bzw. meine Schreib-Lust heute hinführt &#x1f609;.</p>



<h3 class="wp-block-heading">Konkreter Ablauf</h3>



<p>Wenn man sauber vorgeht, sollte man die Daten natürlich in irgendeiner sinnvollen Form vorliegen haben. Nach Möglichkeit gibt es hier also nicht z. B. 15 verschiedene Variablen, Welche dann im schlimmsten Fall noch &#8222;string1, string2, usw.&#8220; heißen. Wir wollen ja im besten Fall mit relativ fest definierten Mustern arbeiten, um unsere Arbeit so einfach wie möglich zu gestalten.</p>



<p>Ich stelle mir einerseits eine bereits definierte Klasse als Daten-Container vor, andererseits könnte es sich auch um analog zugreifbare Daten wie bei einer DataRow handeln. Den konkreten Ablauf würde man  kurz und knapp vielleicht so beschreiben: &#8222;Nimm dieses Ding hier und packe dessen Eigenschafts-Werte in die passenden Steuerelemente&#8220;.</p>



<p>Dabei könnte man entweder ausgehend vom Objekt, oder von der jeweiligen Form arbeiten, also Pseudocode mäßig so:</p>



<pre class="wp-block-code"><code>Für jede Eigenschaft im Objekt, finde die passende Textbox, trage den passenden Wert ein..</code></pre>



<p>oder..</p>



<pre class="wp-block-code"><code>Für jede/s Textbox/Steuerelement auf dem Formular, finde im Ziel-Objekt die passende Eigenschaft und befülle Diese.</code></pre>



<p>Eventuell könnte man hier auch noch für die Performance mit irgendeiner Art Cache arbeiten, oder je nach Situation die &#8222;Strategie&#8220; (Anspielung Strategy-Pattern&#8230;) ändern. Ich werde es hier allerdings nicht weiter als nötig verkomplizieren, da dieses Beispiel nur als Inspiration dienen soll.</p>



<h2 class="wp-block-heading">Code – VB NET Formular automatisch ausfüllen</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formular-automatisch-ausfuellen-mit-Kundendaten.png"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2021/12/VB.NET-Formular-automatisch-ausfuellen-mit-Kundendaten.png" alt="VB.NET Formular automatisch ausfüllen mit Kundendaten" class="wp-image-6786" title="VB.NET Formular automatisch ausfüllen mit Kundendaten"/></a><figcaption>VB.NET Formular automatisch ausfüllen mit Kundendaten</figcaption></figure>



<p>Nachdem wir die Herangehensweise ein wenig durch Pseudocode dargestellt haben, starten wir auch direkt in den Code. Ich werde auf jeden Fall ein Modul verwenden, damit man den Code auch einfach für andere Projekte wiederverwenden kann. Alternativ könnte man natürlich auch eine getrennte Klassenbibliothek, ein NuGet-Paket, o. Ä. erstellen.</p>



<p>Mit gewissen neuen aus C# bekannten Features könnte man auch vielleicht in Visual Basic eine &#8222;Trait&#8220; ähnelnde Verwendungsweise realisieren. Wie bekannt ist, ist Komposition ja zumeist besser, als Vererbung (Stichwort: &#8222;composition over inheritance&#8220;). &#8222;Traits&#8220; kennt man zum Beispiel allzu gut aus der Web-Programmiersprache namens PHP, aber dazu vielleicht in einem anderen Beitrag mehr.</p>



<h3 class="wp-block-heading">Das Modul</h3>



<p>Erstelle nun im ersten Schritt ein neues Modul namens (z. B.) &#8222;modExtensions&#8220; – auch hier verwende ich gerne eine kleine Konvention. Ich halte mich immer an ähnliche Bezeichnungen / Präfixe, wie z. B. &#8222;tb&#8220; für eine Textbox, &#8222;cbb&#8220; für eine Combobox, etc. Welchen Sinn das dann eventuell haben kann / wird, sehen wir unter anderem (und besonders) im heutigen Beitrag!</p>



<p>Da wir schon analog zum Modul geplant haben, eine <a href="https://docs.microsoft.com/de-de/dotnet/visual-basic/programming-guide/language-features/procedures/extension-methods" target="_blank" rel="noreferrer noopener"><strong>Erweiterungsmethode</strong></a> zu verwenden, importieren wir direkt den &#8222;System.Runtime.CompilerServices&#8220;-Namespace.</p>



<h3 class="wp-block-heading">Eine Fill-Methode – VB NET Formular automatisch ausfüllen</h3>



<p>Durch den Import des zuvor genannten Namespaces, können wir dann das &#8222;Extension&#8220;-Attribut verwenden und unsere Methode namens z. B. &#8222;Fill&#8220; damit bestücken.</p>



<p>Als nächstes definieren wir die beiden benötigten Parameter:</p>



<ul class="wp-block-list"><li>Die <strong>Form</strong>, bzw. dessen Steuerelemente, <strong>Welche befüllt werden sollen</strong></li><li>Das <strong>Objekt</strong>, also eine jeweilige Instanz eines x-beliebigen Typs, <strong>Welches </strong>die <strong>Daten beinhaltet</strong></li></ul>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Imports System.Runtime.CompilerServices

Module modExtensions

    &lt;Extension()>
    Public Sub Fill(frm As Form, obj As Object)
        ' ...
    End Sub

End Module</pre>



<p>Danach erfassen wir die Textboxen aus der &#8222;Controls&#8220;-Auflistung des Formulars, damit wir Diese anschließend verwenden können. Praktisch im gleichen Schritt, ziehen wir uns einfach auch direkt die Eigenschaften (Definitionen) des Daten-Objekts.</p>



<p>Das geht relativ einfach, also wie folgt:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim textBoxes = frm.Controls.OfType(Of TextBox)
Dim properties = obj.GetType().GetProperties()</pre>



<p>Danach können wir die eben abgerufenen Textboxen einfach in einer &#8222;For Each&#8220;-Schleife durchlaufen und dann mit dem Befüllen der Eigenschaften beginnen. Im ersten Teil der Schleife prüfen wir, ob die jeweilige Textbox mit dem korrekten Prefix &#8222;tb&#8220; betitelt wurde. Wir halten uns also an eine kleine, von uns festgelegte Konvention. Vielleicht sollte man dies auch durch ein eigenes Attribut konfigurierbar machen, jedoch verzichten wir der Einfachheit halber aktuell darauf. Falls die Textbox nicht mit &#8222;tb&#8220; beginnt, ignorieren wir Sie aktuell einfach, sprich die Schleife springt in den nächsten Durchlauf.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim wrongPrefix = Not tb.Name.StartsWith("tb")
If wrongPrefix Then
    Continue For
End If</pre>



<p>Der darauf folgende Teil prüft, ob wir eine Eigenschaft mit passendem Namen zur Textbox finden können. Ebenso checken wir, ob der Typ zur Textbox passt, es sich dabei also um einen <a href="https://docs.microsoft.com/de-de/dotnet/api/system.string?view=net-6.0" target="_blank" rel="noreferrer noopener">String</a> handelt.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim nameWithoutPrefix = tb.Name.Substring(2)
Dim matchingProperty = properties.SingleOrDefault(Function(x) x.Name = nameWithoutPrefix)
If matchingProperty Is Nothing OrElse matchingProperty.PropertyType IsNot GetType(String) Then
    Continue For
End If</pre>



<p>Der letzte und wichtigste Part – also nach dem Motto &#8222;das Beste kommt zum Schluss&#8220; – ist, die Text-Eigenschaft der Textbox zu setzen:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tb.Text = matchingProperty.GetValue(obj).ToString()</pre>



<p>Dazu verwenden wir die <strong><a href="https://docs.microsoft.com/de-de/dotnet/api/system.reflection.propertyinfo.getvalue?view=net-6.0" target="_blank" rel="noreferrer noopener">&#8222;GetValue&#8220;-Funktion</a></strong> der &#8222;PropertyInfo&#8220;-Klasse, um an den hinterlegten Wert der Eigenschaft zu kommen.</p>



<h2 class="wp-block-heading">Kompletter Code</h2>



<p>Wie immer fasse ich hier am Ende des Beitrages den kompletten Code zusammen.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="kompletter-code">Imports System.Runtime.CompilerServices

Module modExtensions

    &lt;Extension()>
    Public Sub Fill(frm As Form, obj As Object)
        Dim textBoxes = frm.Controls.OfType(Of TextBox)
        Dim properties = obj.GetType().GetProperties()

        For Each tb In textBoxes

            Dim wrongPrefix = Not tb.Name.StartsWith("tb")
            If wrongPrefix Then
                Continue For
            End If

            Dim nameWithoutPrefix = tb.Name.Substring(2)
            Dim matchingProperty = properties.SingleOrDefault(Function(x) x.Name = nameWithoutPrefix)
            If matchingProperty Is Nothing OrElse matchingProperty.PropertyType IsNot GetType(String) Then
                Continue For
            End If

            tb.Text = matchingProperty.GetValue(obj).ToString()
        Next
    End Sub

End Module
</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="kompletter-code">using System;
using System.Windows.Forms;

namespace AutoFillFormCS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnAutoFill_Click(object sender, EventArgs e)
        {
            var customer = new Customer()
            {
                Company = "Nice ltd.",
                FirstName = "Max",
                LastName = "Random",
                Street = "The street",
                HouseNo = "11a"
            };
            this.Fill(customer);
        }
    }
}
</pre>



<h2 class="wp-block-heading">Weiterführende Links</h2>



<ul class="wp-block-list"><li><strong><a href="https://robbelroot.de/blog/mvvm-csharp/" target="_blank" rel="noreferrer noopener">MVVM – Model View ViewModel</a></strong> (Wissen auch für VB geeignet)</li><li><a href="https://robbelroot.de/blog/mahapps-metro-projekt-aufsetzen/" target="_blank" rel="noreferrer noopener"><strong>Mahapps Metro Projekt aufsetzen</strong></a></li><li><strong><a href="https://robbelroot.de/blog/vbnet-await/" target="_blank" rel="noreferrer noopener">Asynchrone Programmierung</a></strong></li></ul>



<h2 class="wp-block-heading">Downloads</h2>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/vbnet/AutoFillForm.zip" target="_blank" rel="noreferrer noopener">AutoFillFormVB.zip</a></div>



<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/vbnet/AutoFillFormCS.zip" target="_blank" rel="noreferrer noopener">AutoFillFormCS.zip</a></div>
</div>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbnet-formular-automatisch-ausfuellen-winforms/">VB NET Formular automatisch ausfüllen (Winforms)</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/vbnet-formular-automatisch-ausfuellen-winforms/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>VB.NET data binding Tutorial</title>
		<link>https://robbelroot.de/blog/vbnet-data-binding-tutorial/</link>
					<comments>https://robbelroot.de/blog/vbnet-data-binding-tutorial/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Wed, 28 Jul 2021 19:06:27 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic .NET]]></category>
		<category><![CDATA[Visual Basic .NET lernen]]></category>
		<category><![CDATA[anleitung]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[binden]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[bindung]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[daten]]></category>
		<category><![CDATA[datenbindung]]></category>
		<category><![CDATA[hilfe]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[visual]]></category>
		<category><![CDATA[visual basic]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=4859</guid>

					<description><![CDATA[<p>VB.NET data binding Tutorial Lerne in diesem VB.NET data binding Tutorial, wie Du Steuerelemente und Daten sauber trennst, indem Du Daten an die Steuerelemente bindest. Besonders seit der WPF (Windows Presentation Foundation) konnte sich ein geordnetes Verhältnis zwischen Daten und dessen Darstellung etablieren. Eventuell hast Du noch später Interesse an &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbnet-data-binding-tutorial/">VB.NET data binding Tutorial</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial.png"><img loading="lazy" decoding="async" width="1024" height="536" src="https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-1024x536.png" alt="VB.NET DataBinding Tutorial" class="wp-image-4861" title="VB.NET DataBinding Tutorial" srcset="https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-1024x536.png 1024w, https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-300x157.png 300w, https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-768x402.png 768w, https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-700x366.png 700w, https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial-332x174.png 332w, https://robbelroot.de/wp-content/uploads/2021/07/VB.NET-DataBinding-Tutorial.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption>VB.NET DataBinding Tutorial</figcaption></figure>






<h2 class="wp-block-heading" id="vb-net-data-binding-tutorial">VB.NET data binding Tutorial</h2>



<p><strong>Lerne </strong>in diesem <strong>VB.NET data binding Tutorial</strong>, wie Du <strong>Steuerelemente </strong>und <strong>Daten </strong>sauber trennst, <strong>indem </strong>Du Daten an die Steuerelemente <strong>bindest</strong>.</p>



<p>Besonders <strong>seit </strong>der <strong>WPF </strong>(Windows Presentation Foundation) <strong>konnte</strong> sich ein geordnetes Verhältnis zwischen <strong>Daten und </strong>dessen <strong>Darstellung </strong>etablieren.</p>



<p><strong>Eventuell </strong>hast Du noch später <strong>Interesse </strong>an diesen Beiträgen: <strong><a href="https://robbelroot.de/blog/wpf-datatemplate/" target="_blank" rel="noreferrer noopener">WPF DataTemplate</a></strong>, <strong><a href="https://robbelroot.de/blog/wpf-stackpanel/" target="_blank" rel="noreferrer noopener">WPF StackPanel</a></strong>, <strong><a href="https://robbelroot.de/blog/mahapps-metro/" target="_blank" rel="noreferrer noopener">MahApps Metro</a></strong>.</p>



<h2 class="wp-block-heading" id="drum-binde-sich-wer-nicht-ewig-prufen-will">Drum binde sich, wer nicht ewig prüfen will</h2>



<p>Das <strong>sagte </strong>der deutsche Immunbiologe und Aphoristiker <strong>Gerhard Uhlenbruck</strong>.</p>



<p><strong>Wie recht </strong>er <strong>auch in </strong>der <strong>Programmierung </strong>mit dieser Aussage haben sollte, war Ihm denke ich nicht bewusst.</p>



<p>Die <strong>Bindung von Daten </strong>an entsprechende <strong>Steuerelemente </strong>bringt verschiedene <strong>Vorteile </strong>mit sich, wovon ich Einige gleich erklären werden.</p>



<h2 class="wp-block-heading" id="damals-war-alles-besser-winforms-zeiten">Damals war alles besser – WinForms-Zeiten</h2>



<p>Es <strong>gibt vermutlich </strong>immer wieder <strong>Verfechter </strong>der Aussage &#8222;damals war alles besser&#8220;, <strong>jedoch ist </strong>dem durchaus <strong>nicht immer so</strong>.</p>



<p>&#8222;<strong>Damals</strong>&#8220; zu WinForms-Zeiten wurde leider <strong>wie </strong>ich es zu <strong>oft erlebt </strong>habe <strong>nicht </strong>&#8222;<strong>sauber</strong>&#8220; mit Daten <strong>umgegangen</strong>.</p>



<p><strong>Einerseits </strong>bei den <strong>Datentypen</strong>, aber wegen vermeintlicher &#8222;Einfachheit&#8220; <strong>auch </strong>oft mit beabsichtigtem <strong>Verzicht auf Datenbindungen</strong>.</p>



<h2 class="wp-block-heading" id="eine-kleine-wiederholung-vb-net-data-binding-tutorial">Eine kleine Wiederholung –  VB.NET data binding Tutorial</h2>



<p>Im Zuge einer <strong>kleinen </strong>W<strong>i</strong>ederholung aus meinem &#8222;<strong><a href="https://robbelroot.de/blog/observablecollection/" target="_blank" rel="noreferrer noopener">ObservableCollection</a></strong>&#8220; Beitrag, möchte ich hier <strong>noch einmal </strong>ein kleines <strong>Beispiel aufgreifen</strong>.</p>



<p>Bei diesem Beispiel <strong>handelt es </strong>sich <strong>um </strong>die Darstellung von simplen <strong><a href="https://docs.microsoft.com/de-de/dotnet/api/microsoft.visualbasic.strings?view=net-5.0" target="_blank" rel="noreferrer noopener">Strings</a></strong> innerhalb einer <strong><a href="https://docs.microsoft.com/de-de/dotnet/api/system.windows.forms.listbox?view=net-5.0" target="_blank" rel="noreferrer noopener">ListBox</a></strong>.</p>



<p>Stelle Dir eine <strong>simple Auflistung </strong>von Strings vor, wo <strong>Elemente eingefügt</strong>, <strong>bearbeitet </strong>und auch <strong>entfernt </strong>werden können.</p>



<p>Eigentlich <strong>nichts </strong>wirklich <strong>Komplexes</strong>, <strong>schaue Dir </strong>allerdings einmal kurz das folgende <strong>Bild an</strong>.</p>



<p>In <strong>diesem Beispiel </strong>ist die <strong>ListBox </strong>tatsächlich <strong>an </strong>eine <strong>Liste </strong>als Datenquelle <strong>gebunden</strong>, <strong>jedoch </strong>gibt es <strong>Probleme</strong>.</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/07/DataBinding-mit-normaler-Liste.gif"><img loading="lazy" decoding="async" width="231" height="195" src="https://robbelroot.de/wp-content/uploads/2021/07/DataBinding-mit-normaler-Liste.gif" alt="DataBinding mit normaler Liste" class="wp-image-4838"/></a><figcaption>DataBinding mit normaler Liste</figcaption></figure>



<h3 class="wp-block-heading" id="darstellungsprobleme">Darstellungsprobleme</h3>



<p><strong>Wie </strong>Du <strong>im Bild</strong> erkennen kannst, <strong>gibt </strong>es <strong>Probleme </strong>mit der <strong>Darstellung</strong>, <strong>obwohl </strong>die <strong>Liste </strong>im Hintergrund Elemente beinhaltet.</p>



<p>Das sich <strong>Elemente in </strong>der <strong>Auflistung </strong>befinden, <strong>zeigt </strong>die beabsichtigt eingefügte <strong>MessageBox </strong>nach kurzer Verzögerung <strong>an</strong>.</p>



<p>Die <strong>nicht angezeigten</strong>, jedoch im Hintergrund <strong>befindlichen Elemente </strong>werden <strong>nicht dargestellt</strong>, <strong>weil </strong>die &#8222;ListBox&#8220; <strong>nichts </strong>von dem Hinzufügen <strong>mitbekommt</strong>.</p>



<p>Sie <strong>merkt </strong>also <strong>nicht</strong>, <strong>dass </strong>die sich dahinter befindliche <strong>Auflistung </strong>tatsächlich <strong>ändert</strong>, also Elemente <strong>hinzugefügt</strong>, oder auch <strong>gelöscht </strong>werden.</p>



<h3 class="wp-block-heading" id="datenbindung-mit-benachrichtigungsmechanismus-vb-net-data-binding-tutorial">Datenbindung mit Benachrichtigungsmechanismus –  VB.NET data binding Tutorial </h3>



<p>Das <strong>beschriebene Problem </strong>können wir mit einer Art <strong>Benachrichtigungsmechanismus </strong>lösen.</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/07/Indirekte-Modifikation-der-ListBox-durch-DatenQuelle.png"><img loading="lazy" decoding="async" width="646" height="385" src="https://robbelroot.de/wp-content/uploads/2021/07/Indirekte-Modifikation-der-ListBox-durch-DatenQuelle.png" alt="Indirekte Modifikation der ListBox durch DatenQuelle" class="wp-image-4830" title="Indirekte Modifikation der ListBox durch DatenQuelle" srcset="https://robbelroot.de/wp-content/uploads/2021/07/Indirekte-Modifikation-der-ListBox-durch-DatenQuelle.png 646w, https://robbelroot.de/wp-content/uploads/2021/07/Indirekte-Modifikation-der-ListBox-durch-DatenQuelle-300x179.png 300w, https://robbelroot.de/wp-content/uploads/2021/07/Indirekte-Modifikation-der-ListBox-durch-DatenQuelle-332x198.png 332w" sizes="auto, (max-width: 646px) 100vw, 646px" /></a><figcaption>Indirekte Modifikation der ListBox durch DatenQuelle</figcaption></figure>



<p><strong>Dabei wird </strong>die <strong>Veränderung </strong>der Datenquelle <strong>durch </strong>z. B. <strong>Ereignisse </strong>an die Abonnenten dieser Ereignisse <strong>kommuniziert</strong>.</p>



<p>Diesen <strong>Mechanismus </strong>können wir <strong>durch </strong>die <strong>Implementierung </strong>der &#8222;<strong>IRaiseItemChangedEvents</strong>&#8222;-Schnittstelle erreichen.</p>



<h3 class="wp-block-heading" id="vorhandene-bordmittel-nutzen">Vorhandene Bordmittel nutzen</h3>



<p><strong>Statt </strong>diese <strong>Schnittstelle </strong>selbst zu <strong>implementieren </strong>und somit eine eigene Klasse zu erstellen, <strong>können </strong>wir <strong>auch </strong>auf die <strong>bestehenden Klassen </strong>zurückgreifen.</p>



<p>Zum <strong>Glück </strong>gibt uns das .NET-<strong>Framework </strong>für <strong>WinForms</strong>-Anwendungen z. B. die &#8222;BindingList&#8220;-Klasse an die Hand.</p>



<p><strong>Für </strong>modernere <strong>WPF</strong>&#8211;<strong>Anwendungen </strong>(Windows Presentation Foundation) können wir die <strong>vorhandene </strong>&#8222;<strong>ObservableCollection</strong>&#8222;-Klasse verwenden.</p>



<p><strong>Nach </strong>diesem kleinen <strong>Rückblick </strong>werden wir unseren Blick <strong>nun </strong>in Richtung diverser <strong>Beispiele </strong>richten.</p>



<h2 class="wp-block-heading" id="databinding-voraussetzungen">Voraussetzungen –  VB.NET data binding Tutorial </h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-Voraussetzungen.jpg"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-Voraussetzungen.jpg" alt="VB.NET data binding Tutorial - Voraussetzungen" class="wp-image-9406" title="VB.NET data binding Tutorial - Voraussetzungen"/></a><figcaption>VB.NET data binding Tutorial &#8211; Voraussetzungen</figcaption></figure>



<pre class="wp-block-verse"><strong>Damit </strong>viele, bzw. gar alle der nächsten <strong>Beispiele funktionieren</strong>, musst Du bei der verwendeten Klasse die "<strong>INotifyPropertyChanged</strong>"-<strong>Schnittstelle implementieren</strong>.</pre>



<h3 class="wp-block-heading" id="implementierung-inotifypropertychanged-schnittstelle">Implementierung INotifyPropertyChanged-Schnittstelle</h3>



<p>Eine <strong>beispielhafte Implementierung </strong>der &#8220; <strong>INotifyPropertyChanged</strong>&#8222;-Schnittstelle kann wie gleich folgend aussehen.</p>



<p><strong>Ausgehend </strong>davon, dass wir eine <strong>Eigenschaft namens </strong>&#8222;TextBoxText&#8220; in der Form haben:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="property-changed-helper">Private _textBoxtext As String

Public Property TextBoxText As String
    Get
        Return _textBoxtext
    End Get
    Set(value As String)
        If _textBoxtext = value Then
            Return
        End If
        _textBoxtext = value
        ' raise something like "hey, i changed my value!"
    End Set
End Property</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="property-changed-helper">private string _textBoxText;

public string TextBoxText
{
    get
    {
        return _textBoxText;
    }
    set
    {
        if (_textBoxText == value)
            return;
        _textBoxText = value;
        // raise something like "hey, i changed my value!"
    }
}</pre>



<p><strong>definieren </strong>wir zuerst einen <strong>privaten Member </strong>namens &#8222;<strong>_textBoxtext</strong>&#8222;, Welcher als <strong>Hintergrund</strong>&#8211;<strong>Feld für </strong>die <strong>Eigenschaft </strong>dient.</p>



<h3 class="wp-block-heading" id="eigenschaft-definieren">Eigenschaft definieren</h3>



<p><strong>Danach </strong>erstellen wir eine <strong>Eigenschaft</strong>, die dieses Feld verwendet, <strong>wobei </strong>der <strong>Setter </strong>hier das <strong>Interessante </strong>ist.</p>



<p>Der <strong>Setter überprüft </strong>zuerst, <strong>ob </strong>sich der aktuelle <strong>Wert </strong>des Feldes tatsächlich vom übergebenen Wert <strong>unterscheidet</strong>.</p>



<p><strong>Wenn </strong>die <strong>Werte </strong>sowieso schon die &#8222;<strong>Gleichen</strong>&#8220; <strong>sind</strong>, <strong>verlassen </strong>wir den <strong>Setter </strong>durch &#8222;Early-Return&#8220;.</p>



<p><strong>Da </strong>die <strong>Werte </strong>sich <strong>unterscheiden</strong>, <strong>wenn </strong>wir <strong>nicht </strong>vorher schon <strong>per Return</strong> rausgesprungen sind, <strong>setzen </strong>wir dann den <strong>neuen Wert</strong>.</p>



<h3 class="wp-block-heading" id="helper-methode-vb-net-data-binding-tutorial">Helper-Methode –  VB.NET data binding Tutorial </h3>



<p><strong>Nun </strong>kommen wir zum <strong>besonderen Part </strong>der <strong>Eigenschaft</strong>, denn <strong>jetzt kommunizieren </strong>wir die tatsächlichen <strong>Änderungen </strong>der Eigenschaft <strong>an </strong>eventuell <strong>Interessierte</strong>.</p>



<p><strong>Um </strong>dazu jedoch <strong>nicht </strong>für jede einzelne Property zig Zeilen <strong>Code zu wiederholen</strong>, <strong>habe </strong>ich mir eine kleine <strong>Helper-Methode geschrieben</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="property-changed-helper-method">Private Sub NotifyOfPropertyChange(&lt;CallerMemberName> Optional propertyName As String = Nothing)
    If propertyName Is Nothing Then
        Return
    End If
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="property-changed-helper-method">private void NotifyOfPropertyChange([CallerMemberName] string propertyName = null)
{
    if (propertyName == null)
        return;
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName))
}</pre>



<h3 class="wp-block-heading" id="property-changed-auslösen">Änderungen der Eigenschaft kommunizieren</h3>



<p><strong>Ersetze </strong>den vorhin bereits <strong>angeführten Kommentar </strong>nun <strong>durch </strong>einen Aufruf der <strong>Helper-Methode</strong>.</p>



<p><strong>Beachte </strong>dabei, dass Du <strong>durch </strong>die tolle Funktionalität des &#8222;<strong>CallerMemberName</strong>&#8222;-Attributs des Parameters keinen Namen angeben musst.</p>



<p>Der <strong>Name </strong>der <strong>Eigenschaft wird </strong>hier im Setter durch dieses Attribut <strong>automatisch befüllt</strong>, lasse Dir den Wert ggf. einmal in verschiedenen Fällen ausgeben.</p>



<p><strong>Diese </strong>kleine <strong>Methode </strong>hat mir <strong>selbst schon </strong>sehr <strong>oft </strong>die Arbeit bei <strong>Datenbindungen </strong>wie in dem <strong>VB.NET data binding Tutorial</strong> erleichtert.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="property-changed-auslösen">Private _textBoxtext As String

Public Property TextBoxText As String
    Get
        Return _textBoxtext
    End Get
    Set(value As String)
        If _textBoxtext = value Then
            Return
        End If
        _textBoxtext = value
        NotifyOfPropertyChange()
    End Set
End Property</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="property-changed-auslösen">private string _textBoxText;

public string TextBoxText
{
    get
    {
        return _textBoxText;
    }
    set
    {
        if (_textBoxText == value)
            return;
        _textBoxText = value;
        NotifyOfPropertyChange();
    }
}</pre>



<h3 class="wp-block-heading" id="wann-anderungen-kommuniziert-werden">Wann Änderungen kommuniziert werden </h3>



<pre class="wp-block-verse"><strong>Beachte</strong>, <strong>dass </strong>die <strong>TextBox </strong>die <strong>Änderungen </strong>selbst erst an die Eigenschaft kommuniziert, <strong>wenn </strong>Du die <strong>TextBox verlässt</strong>! Dies <strong>kannst Du </strong>anderweitig <strong>konfigurieren</strong>, <strong>indem </strong>Du <strong>weitere Parameter </strong>der <strong>Add</strong>-Methode definierst.</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Add("Text", Me, "TextBoxText", False, DataSourceUpdateMode.OnPropertyChanged)</pre>



<p><strong>Genauer genommen </strong>geht es hier um den <strong>letzten Parameter </strong>namens &#8222;<strong>updateMode</strong>&#8222;, Welche wir nun einmal auf den Wert 1 (<strong>DataSourceUpdateMode.OnPropertyChanged</strong>) stellen.</p>



<h3 class="wp-block-heading" id="weitere-abhangige-eigenschaften">Weitere abhängige Eigenschaften</h3>



<p><strong>Vielleicht</strong> hast Du auch andere Eigenschaften, also zum <strong>Beispiel </strong>eine <strong>Eigenschaft </strong>wie &#8222;<strong>FullName</strong>&#8222;, Welche vom &#8222;<strong>First</strong>-&#8222;, sowie vom &#8222;<strong>LastName</strong>&#8220; abhängig ist.</p>



<p><strong>Dann </strong>kannst Du einen <strong>weiteren Aufruf </strong>der Helper-Methode <strong>mit </strong>der abhängigen <strong>Eigenschaft durchführen</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">NotifyOfPropertyChange("&lt;TheDependentProperty>")</pre>



<h2 class="wp-block-heading" id="winforms-beispiele-vb-net-data-binding-tutorial">WinForms Beispiele – VB.NET data binding Tutorial</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-Winforms-Beispiele.jpg"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-Winforms-Beispiele.jpg" alt="VB.NET data binding Tutorial - Winforms Beispiele" class="wp-image-9408" title="VB.NET data binding Tutorial - Winforms Beispiele"/></a><figcaption>VB.NET data binding Tutorial &#8211; Winforms Beispiele</figcaption></figure>



<p>In <strong>diesem Abschnitt </strong>versuche ich mit der Darstellung <strong>diverser Beispiele </strong>das <strong>Thema Datenbindung unter WinForms </strong>ein wenig näher zu bringen.</p>



<p><strong>Keine Sorge</strong>, in diesem <strong>VB.NET data binding Tutorial</strong> werde ich auch noch auf <strong>Beispiele </strong>für <strong>WPF </strong>eingehen, falls Du eher <strong>daran interessiert </strong>bist.</p>



<p><strong>Neben </strong>den bereits <strong>angeführten </strong>Auflistungen gibt es natürlich auch <strong>weitere Datenbindungen wie </strong>z. B. an einen <strong>Text</strong>.</p>



<p>Finde hier alle gängigen WinForms-Beispiele für das <strong>VB.NET data binding Tutorial</strong>.</p>



<h3 class="wp-block-heading" id="textbox-text-an-string-binden">TextBox Text an String binden</h3>



<p>Im <strong>ersten Beispiel </strong>realisieren wir eine kleine <strong>Datenbindung</strong>, Welche den eingegebenen <strong>Text </strong>einer <strong>TextBox </strong>innerhalb eines <strong>Labels widerspiegelt</strong>.</p>



<p>Als <strong>Eigenschaft </strong>verwende ich dafür das <strong><a href="#databinding-voraussetzungen">oben angeführte Beispiel</a></strong> aus den Voraussetzungen.</p>



<p><strong>Sage nun </strong>der <strong>TextBox </strong>durch folgenden Code, <strong>dass </strong>Sie Ihren <strong>Text</strong>, <strong>an</strong> die &#8222;TextBoxText&#8220;-<strong>Eigenschaft</strong> <strong>binden </strong>soll:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="textbox-binding">tbTextBoxBinding.DataBindings.Add("Text", Me, "TextBoxText")</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="textbox-binding">tbTextBoxBinding.DataBindings.Add("Text", this, "TextBoxText");</pre>



<p><strong>Nun </strong>wird <strong>bereits </strong>die <strong>TextBox </strong>in der Lage sein, <strong>Änderungen </strong>an der Eigenschaft in ihrem Text <strong>widerzuspiegeln</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">TextBoxText = "My New Text"</pre>



<p><strong>Was </strong>allerdings <strong>noch fehlt</strong>, <strong>ist </strong>das oben angesprochene <strong>Label</strong>, Welches die <strong>Zeichenfolge ebenfalls darstellen </strong>soll.</p>



<p><strong>Dafür rufen </strong>wir auch einfach nur die &#8222;Add&#8220;-<strong>Methode </strong>der <strong>DataBindings</strong>-Eigenschaft des Labels auf:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="label-binding">lblTextBoxBinding.DataBindings.Add("Text", Me, "TextBoxText")</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="label-binding">lblTextBoxBinding.DataBindings.Add("Text", this, "TextBoxText");</pre>



<p>Und <strong>schon </strong>ist das <strong>Label bereit</strong>, die <strong>Änderungen </strong>der &#8222;TextBoxText&#8220;-Eigenschaft ebenfalls <strong>darzustellen</strong>.</p>



<h3 class="wp-block-heading" id="checkbox-an-boolean-binden">CheckBox an Boolean binden</h3>



<p>Als <strong>nächstes </strong>beschäftigen wir uns mit der <strong>Datenbindung </strong>eines <strong>Booleans an </strong>eine <strong>CheckBox</strong>.</p>



<p><strong>Ziehe dafür </strong>auch hier ein <strong>Label und </strong>dieses mal eine <strong>CheckBox auf </strong>die <strong>Form</strong>, rufe danach <strong>folgende Anweisungen </strong>z. B. im Load-Ereignis der Form auf.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="checkbox-binding">chbCheckBoxBinding.DataBindings.Add("Checked", Me, "CheckBoxBool", False, DataSourceUpdateMode.OnPropertyChanged)
lblCheckBoxBinding.DataBindings.Add("Text", Me, "CheckBoxBool", False, DataSourceUpdateMode.OnPropertyChanged)</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="checkbox-binding">chbCheckBoxBinding.DataBindings.Add("Checked", Me, "CheckBoxBool", False, DataSourceUpdateMode.OnPropertyChanged)
lblCheckBoxBinding.DataBindings.Add("Text", Me, "CheckBoxBool", False, DataSourceUpdateMode.OnPropertyChanged)</pre>



<h3 class="wp-block-heading" id="listbox-an-simple-auflistung-binden">ListBox an simple Auflistung binden</h3>



<p>Hier ein <strong>einfaches Beispiel</strong>, wie Du eine <strong>einfache Auflistung </strong>(Integer, String, ..) an eine <strong>ListBox binden </strong>kannst.</p>



<p><strong>Erstelle </strong>z. B. eine <strong>Eigenschaft </strong>namens &#8222;<strong>StringList</strong>&#8220; vom <strong>Typ BindingList</strong>, Welche gleich die einzelnen Items beinhalten wird.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="string-list-binding">Public Property StringList As BindingList(Of String)</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="string-list-binding">public BindingList&lt;string> StringList { get;set; }</pre>



<p>Für das <strong>Download-Beispiel</strong> habe ich die folgende<strong> Methode </strong>definiert und im <strong>Load-Ereignishandler</strong> der Form <strong>aufgerufen</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="prepare-listbox-binding-method">Private Sub PrepareListBoxBinding()
    StringList = New BindingList(Of String)()
    For i = 1 To 3
        StringList.Add($"Item {i}")
    Next
    lbSimpleStringBinding.DataSource = StringList
End Sub</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="prepare-listbox-binding-method">private void PrepareListBoxBinding()
{
    StringList = new BindingList&lt;string>();
    for (var i = 0; i &lt;= 3; i++)
    {
        StringList.Add($"Item {i}");
    }
    lbSimpleStringBinding.DataSource = StringList;
}</pre>



<h3 class="wp-block-heading" id="datagridview-datenbindung-mit-objekten">DataGridView Datenbindung mit Objekten</h3>



<p><strong>Ähnlich wie </strong>mit der <strong>ListBox </strong>kann man <strong>auch bei </strong>einem <strong>DataGridView </strong>verfahren, das <strong>heißt </strong>man <strong>legt </strong>die <strong>DataSource </strong>fest <strong>und konfiguriert </strong>noch ein wenig.</p>



<p><strong>Standardmäßig generiert </strong>das <strong>DataGridView Spalten </strong>bei <strong>Datenbindungen automatisch</strong>, <strong>leider </strong>hat das dann <strong>auch ggf</strong>. <strong>ungewollte </strong>Spalten zur Folge.</p>



<p>Wir <strong>können </strong>dieses <strong>Verhalten deaktivieren</strong>, <strong>indem </strong>wir die &#8222;<strong>AutoGenerateColumns</strong>&#8222;-Eigenschaft <strong>auf False </strong>stellen <strong>und </strong>die <strong>Spalten </strong>z. B. im Designer <strong>selbst bestimmen</strong>.</p>



<pre class="wp-block-verse">Achtung! Die "<strong>AutoGenerateColumns</strong>"-Eigenschaft ist leider <strong>nicht in </strong>den <strong>Designer</strong>-<strong>Eigenschaften </strong>des <strong>DataGrids </strong>aufzufinden. <strong>Daher </strong>müssen wir Diese <strong>über </strong>den <strong>Code setzen</strong>.</pre>



<p>Gehe dazu <strong>im Designer auf </strong>die <strong>3 Punkte</strong> <strong>der &#8222;Columns&#8220;</strong>-Eigenschaft und klicke <strong>dann </strong>im erscheinenden Fenster <strong>links </strong>auf &#8222;<strong>Hinzufügen</strong>&#8222;.</p>



<p><strong>Gebe </strong>der <strong>Spalte </strong>dann einen <strong>eindeutigen Namen </strong>und <strong>lege </strong>den <strong>Typ </strong>sowie den <strong>Header</strong>&#8211;<strong>Text fest</strong>.</p>



<p>Wenn Du <strong>dann </strong>auf <strong>Hinzufügen und </strong>danach auf <strong>schließen </strong>klickst, kannst Du <strong>weitere Einstellungen </strong>der Spalte festlegen.</p>



<p>Die <strong>wichtigste Einstellung </strong>ist wohl der &#8222;DataPropertyName&#8220;, Dieser bestimmt, <strong>welche </strong>der <strong>Eigenschaften </strong>der gebundenen Elemente <strong>in </strong>dieser<strong> Spalte dargestellt </strong>werden.</p>



<h2 class="wp-block-heading" id="wpf-beispiele-vb-net-data-binding-tutorial">WPF Beispiele – VB.NET data binding Tutorial</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-WPF-Beispiele.jpg"><img loading="lazy" decoding="async" width="1200" height="628" src="https://robbelroot.de/wp-content/uploads/2022/02/VB.NET-data-binding-Tutorial-WPF-Beispiele.jpg" alt="VB.NET data binding Tutorial - WPF Beispiele" class="wp-image-9411" title="VB.NET data binding Tutorial - WPF Beispiele"/></a><figcaption>VB.NET data binding Tutorial &#8211; WPF Beispiele</figcaption></figure>



<p>Hier <strong>folgen </strong>nun einige <strong>WPF-Beispiele</strong> des  <strong>VB.NET data binding Tutorial</strong>, einen <strong>Vorgeschmack </strong>siehst Du im <strong>animierten Bild </strong>hier drunter:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/07/WPF-DataBinding-Example.gif"><img loading="lazy" decoding="async" width="164" height="216" src="https://robbelroot.de/wp-content/uploads/2021/07/WPF-DataBinding-Example.gif" alt="WPF DataBinding Example" class="wp-image-4936" title="WPF DataBinding Example"/></a><figcaption>WPF DataBinding Example</figcaption></figure>



<h3 class="wp-block-heading" id="textbox-und-textblock-an-string-binden">TextBox und TextBlock an String binden</h3>



<p>Im ersten <strong>XAML Code</strong>, <strong>erstellen </strong>wir eine <strong>GroupBox mit </strong>einem <strong>StackPanel </strong>und den dann zu bindenden Controls.</p>



<p><strong>Darunter </strong>eine <strong>TextBox</strong>, um den <strong>Text einzugeben und </strong>der <strong>TextBlock</strong>, der die <strong>Daten sofort </strong>bei Änderung <strong>anzeigt</strong>.</p>



<p><strong>Wie </strong>auch <strong>im WinForms-Beispiel </strong>müssen wir den <strong>Zeitpunkt zum updaten </strong>der Daten konfigurieren.</p>



<p>Bei <strong>WPF</strong> machen wir das mit der &#8222;<strong>UpdateSourceTrigger</strong>&#8222;-Eigenschaft und dem Wert &#8222;<strong>PropertyChanged</strong>&#8222;.</p>



<p><strong>Auch hier </strong>kannst Du die <strong><a href="#property-changed-auslösen">Eigenschaft von oben</a></strong> verwenden.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;GroupBox Header="TextBox">
    &lt;StackPanel>
        &lt;TextBox Text="{Binding TextBoxText, UpdateSourceTrigger=PropertyChanged}" />
        &lt;TextBlock Text="{Binding TextBoxText}" />
    &lt;/StackPanel>
&lt;/GroupBox></pre>



<h3 class="wp-block-heading" id="checkbox-an-boolean-binden">CheckBox an Boolean binden</h3>



<p>Um eine <strong>CheckBox </strong>an einen <strong>Boolean </strong>zu <strong>binden</strong>, <strong>benötigst </strong>Du diesen hier drunter geschrieben <strong>XAML-Code</strong>.</p>



<p>Die &#8222;<strong>IsChecked</strong>&#8222;-<strong>Eigenschaft </strong>der CheckBox <strong>wird </strong>hier <strong>an </strong>die <strong>Boolean</strong>-Eigenschaft <strong>der Form </strong>namens &#8222;CheckBoxBool&#8220; <strong>gebunden</strong>.</p>



<p>Um <strong>Feedback </strong>zu <strong>erhalten </strong>und zu sehen, <strong>wann </strong>die <strong>Änderungen </strong>an die Eigenschaft <strong>kommuniziert </strong>werden, <strong>stelle </strong>ich das Ganze noch <strong>in </strong>einem <strong>TextBlock dar</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;GroupBox Header="CheckBox">
    &lt;StackPanel>
        &lt;CheckBox IsChecked="{Binding CheckBoxBool}" />
        &lt;TextBlock Text="{Binding CheckBoxBool}" />
    &lt;/StackPanel>
&lt;/GroupBox></pre>



<h3 class="wp-block-heading" id="observablecollection-an-listbox-und-datagrid-binden">ObservableCollection an ListBox und DataGrid binden</h3>



<p><strong>Für </strong>die <strong>listen</strong>-basierten <strong>Beispiele </strong>wirst Du eine Auflistung wie Diese hier brauchen:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="observable-customers-collection">Public Property Customers As ObservableCollection(Of Customer)</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="observable-customers-collection">public Customers As ObservableCollection&lt;Customer> { get; set; }</pre>



<p>Diese <strong>können </strong>wir dann wie folgt <strong>vorbereiten </strong>(am besten <strong>im Konstruktor aufrufen</strong>):</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="prepare-customers-observablecollection">Private Sub PrepareCustomers()
    Customers = New ObservableCollection(Of Customer)
    Customers.Add(New Customer("John", "Doe"))
    Customers.Add(New Customer("Maximilian", "Doe"))
    Customers.Add(New Customer("Robert", "Doe"))
End Sub</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="prepare-customers-observablecollection">private void PrepareCustomers()
    Customers = New ObservableCollection(Of Customer);
    Customers.Add(new Customer("John", "Doe"));
    Customers.Add(new Customer("Maximilian", "Doe"));
    Customers.Add(new Customer("Robert", "Doe"));
End Sub</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;GroupBox Header="ListBox" Height="80">
    &lt;ScrollViewer VerticalScrollBarVisibility="Auto">
        &lt;ListBox ItemsSource="{Binding Customers }" />
    &lt;/ScrollViewer>
&lt;/GroupBox></pre>



<p><strong>Hier </strong>siehst Du einen beispielhaften <strong>Code</strong>, um die <strong>Customers als Datenquelle </strong>für eine ListBox zu verwenden:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;GroupBox Header="DataGrid" Height="80">
    &lt;DataGrid ItemsSource="{Binding Customers }" AutoGenerateColumns="False">
        &lt;DataGrid.Columns>
            &lt;DataGridTextColumn Binding="{Binding FirstName}" />
            &lt;DataGridTextColumn Binding="{Binding LastName}" />
        &lt;/DataGrid.Columns>
    &lt;/DataGrid>
&lt;/GroupBox></pre>



<p>Und <strong>hier </strong>wäre der passende <strong>Code für </strong>das <strong>DataGrid</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;GroupBox Header="DataGrid" Height="80">
    &lt;DataGrid ItemsSource="{Binding Customers }" AutoGenerateColumns="False">
        &lt;DataGrid.Columns>
            &lt;DataGridTextColumn Binding="{Binding FirstName}" />
            &lt;DataGridTextColumn Binding="{Binding LastName}" />
        &lt;/DataGrid.Columns>
    &lt;/DataGrid>
&lt;/GroupBox></pre>



<h2 class="wp-block-heading" id="downloads-vb-net-data-binding-tutorial">Downloads –  VB.NET data binding Tutorial</h2>



<p>Hier findest Du alle Downloads zum <strong>VB.NET data binding Tutorial</strong>:</p>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/vbnet/WinFormsDataBindingExampleVB.zip" target="_blank" rel="noreferrer noopener">WinFormsDataBindingExampleVB.zip</a></div>



<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/cs/WinFormsDataBindingExampleCS.zip" target="_blank" rel="noreferrer noopener">WinFormsDataBindingExampleCS.zip</a></div>



<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/vbnet/WpfDatabindingExampleVB.zip" target="_blank" rel="noreferrer noopener">WpfDatabindingExampleVB.zip</a></div>



<div class="wp-block-button"><a class="wp-block-button__link" href="/downloads/cs/WpfDatabindingExampleCS.zip" target="_blank" rel="noreferrer noopener">WpfDatabindingExampleCS.zip</a></div>
</div>



<p></p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbnet-data-binding-tutorial/">VB.NET data binding Tutorial</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/vbnet-data-binding-tutorial/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>TextBox mit Wasserzeichen</title>
		<link>https://robbelroot.de/blog/textbox-mit-wasserzeichen/</link>
					<comments>https://robbelroot.de/blog/textbox-mit-wasserzeichen/#respond</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sun, 07 Feb 2016 19:48:11 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic .NET]]></category>
		<category><![CDATA[Visual Basic .NET Problemlösungen]]></category>
		<category><![CDATA[tb]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[visual basic]]></category>
		<category><![CDATA[wasser]]></category>
		<category><![CDATA[wasserzeichen]]></category>
		<category><![CDATA[watermark]]></category>
		<category><![CDATA[zeichen]]></category>
		<guid isPermaLink="false">http://robbelroot.de/?p=854</guid>

					<description><![CDATA[<p>Auf YouTube ansehen Code Download</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/textbox-mit-wasserzeichen/">TextBox mit Wasserzeichen</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async=""></script><!-- robbelroot.de pre content --><ins class="adsbygoogle" style="display: inline-block; width: 468px; height: 60px;" data-ad-client="ca-pub-3635281460831831" data-ad-slot="4378945418"></ins><script>// <![CDATA[
(adsbygoogle = window.adsbygoogle || []).push({});
// ]]&gt;</script></p>
<p style="margin-bottom:0;">
<a class="fasc-button fasc-size-medium fasc-type-glossy fasc-rounded-medium fasc-ico-before dashicons-format-video" style="background-color: #ff0000; color: #ffffff;" href="https://www.youtube.com/watch?v=55woDWdLwIo" target="_blank" data-fasc-style="background-color:#ff0000;color:#ffffff;">Auf YouTube ansehen</a> <a class="fasc-button fasc-size-medium fasc-type-glossy fasc-rounded-medium fasc-ico-before dashicons-download" style="background-color: #339e48; color: #ffffff;" href="https://adf.ly/qwaUc" target="_blank" data-fasc-style="background-color:#339e48;color:#ffffff;">Code Download</a>
</p>
<p><iframe loading="lazy" width="560" height="315" src="https://www.youtube.com/embed/55woDWdLwIo" frameborder="0" allowfullscreen></iframe></p>
<p><script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async=""></script><!-- robbelroot.de pre content --><ins class="adsbygoogle" style="display: inline-block; width: 468px; height: 60px;" data-ad-client="ca-pub-3635281460831831" data-ad-slot="4378945418"></ins><script>// <![CDATA[
(adsbygoogle = window.adsbygoogle || []).push({});
// ]]&gt;</script></p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/textbox-mit-wasserzeichen/">TextBox mit Wasserzeichen</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/textbox-mit-wasserzeichen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Text in TextBox auswählen</title>
		<link>https://robbelroot.de/blog/text-in-textbox-auswaehlen/</link>
					<comments>https://robbelroot.de/blog/text-in-textbox-auswaehlen/#respond</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sun, 07 Feb 2016 17:53:26 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic .NET]]></category>
		<category><![CDATA[Visual Basic .NET Problemlösungen]]></category>
		<category><![CDATA[auswählen]]></category>
		<category><![CDATA[markieren]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[selection]]></category>
		<category><![CDATA[selectionlength]]></category>
		<category><![CDATA[selectionstart]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[visual basic]]></category>
		<guid isPermaLink="false">http://robbelroot.de/?p=802</guid>

					<description><![CDATA[<p>Auf YouTube ansehen Code Download</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/text-in-textbox-auswaehlen/">Text in TextBox auswählen</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="<script&gt;" title="<script&gt;"/></figure>



<figure class="wp-block-image"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="<script&gt;" title="<script&gt;"/></figure>



<p><!-- robbelroot.de pre content --><ins class="adsbygoogle" style="display: inline-block; width: 468px; height: 60px;" data-ad-client="ca-pub-3635281460831831" data-ad-slot="4378945418"></ins></p>



<p><a class="fasc-button fasc-size-medium fasc-type-glossy fasc-rounded-medium fasc-ico-before dashicons-format-video" style="background-color: #ff0000; color: #ffffff;" target="_blank" rel="noopener" href="https://www.youtube.com/watch?v=WOVytg3P_I0">Auf YouTube ansehen</a> <a class="fasc-button fasc-size-medium fasc-type-glossy fasc-rounded-medium fasc-ico-before dashicons-download" style="background-color: #339e48; color: #ffffff;" target="_blank" rel="noopener" href="https://adf.ly/koBqj">Code Download</a></p>



<p><iframe loading="lazy" src="https://www.youtube.com/embed/WOVytg3P_I0" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>



<figure class="wp-block-image"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="<script&gt;" title="<script&gt;"/></figure>



<figure class="wp-block-image"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="<script&gt;" title="<script&gt;"/></figure>



<p><!-- robbelroot.de pre content --><ins class="adsbygoogle" style="display: inline-block; width: 468px; height: 60px;" data-ad-client="ca-pub-3635281460831831" data-ad-slot="4378945418"></ins></p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/text-in-textbox-auswaehlen/">Text in TextBox auswählen</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/text-in-textbox-auswaehlen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
