Reputation: 916 Master
- Active Posts:
- 921 (0.96 per day)
- 30-September 10
- Profile Views:
- Last Active:
- Today, 02:53 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Who Cares
- Dream Kudos:
- Expert In:
13 May 2013 - 10:40
12 May 2013 - 04:38
05 May 2013 - 19:00
05 May 2013 - 07:36
02 May 2013 - 10:51
17 Apr 2013 - 15:02
13 Apr 2013 - 10:25
10 Apr 2013 - 09:55
02 Apr 2013 - 13:18
01 Apr 2013 - 13:18
Posts I've Made
Posted 5 Apr 2013
Quotei know that the DispatcherTimer will run on it on seperate thread
Actually, the DispatcherTimer's Tick event is raised on the UI thread.
Quotewould the getX function be running on the same thread as the DispatcherTimer thread
Posted 2 Apr 2013To get the hosting window, you can use the window.GetWindow() method, passing in a reference to the hosted DependencyObject (your Page in this case).
Posted 23 Mar 2013This:
Dim p2 As People
is just declaring a variable that points to nothing. You need to instantiate a People object to be able to use it, like so:
Dim p2 As New People("Name")
Now p2 refers to the new Person object, and you can use it.
If, on the other hand, GetCustomer() is meant to be a Factory Method that creates a new People object with the specified name, you want GetCustomer() to be marked as Shared, and you want it to return a Person object, rather than a String.
For example (I've changed the name of the method to reflect what it now does):
Public Shared Function CreateCustomer(ByVal name As String) As People Return New People("New " & name) End Function
You can then call it like this:
Dim p As New List(Of People) Dim p2 As People = People.CreateCustomer("Howard") p.Add(p2)
However, having a method called CreateCustomer() that returns a People object is a bit bizarre, as is having a People class that takes a single name in its constructor (should the class be called Person instead?), so you may have to explain what you are trying to do a bit more.
Posted 22 Mar 2013The EventHandler delegate is expecting you to pass it a method with the following signature and return type:
void YourMethod(object sender, EventArgs e)
Compare that to the signature of your TextBox_KeyDown method.
Happily, there is a built in delegate that can reference a method with a signature and return type like your method's that you can you use instead - KeyEventHandler.
If you look at the MSDN pages for a given delegate (like the two I linked above), you can see the signature and return type of the method they can handle from their declaration displayed in the 'Syntax' section of the page. Also, in Visual Studio, if you type this.TextBox.KeyDown +=, and then hit tab, it should insert the right hand operand of the += operator for you. EDIT 2: Finally, note that you can get the delegate type that backs a given event on the event's MSDN page - Control.KeyDown. Note the KeyEventHandler part in the declaration of the event. You should use the same delegate type when subscribing to an event as is used in the declaration of the event.
Note that if you are using C# 2.0 or above, you can let the compiler decide what delegate to use using the method group conversion feature, as so:
this.TextBox.KeyDown += this.TextBox_KeyDown;
Posted 22 Mar 2013Yes, I think you've got it. The rich text box is ultimately contained in the form, so it won't outlive the form.
- Member Title:
- D.I.C Addict
- 20 years old
- June 11, 1992
- United Kingdom
Rock/metal music - Led Zeppelin, Guns N' Roses, Metallica, Nirvana, AC/DC etc
Coding. Love C#, in particular.
Online gaming (Xbox 360).
- Full Name:
- Years Programming:
- Programming Languages:
- C#, a bit of Actionscript 3.0 ,SQL,Progress4GL, VB.NET. Learning Java, and Assembly/C/C++ when I can.
- Click here to e-mail me