Solved

Threading is not a member of windows... vb.net

Posted on 2014-10-28
2
704 Views
Last Modified: 2014-10-28
At line 22, I am getting two error notes:  

Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, DirectCast(Sub() element.Focus(),

Dispatcher: Dispacher is not declared. It may be inaccessible due to its protection level.
System.Windows.Threading: Threading is not a member of windows

Question: How can I fix this?

Please, in addition to description of the direction, give me the syntax for my use.


tabcontrol.IsSelected=true;
PutFocusOnControl(textBox1);
and define the method...

 private void PutFocusOnControl(Control element)
        {
            if (element != null)
                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input,
                    (System.Threading.ThreadStart)delegate
                    {
                        element.Focus();
                    });
        }

or:

                TabControl1.SelectedTab = tabChannels
                PutFocusOnControl(txtChannels_channel)

    Private Sub PutFocusOnControl(element As Control)
        If element IsNot Nothing Then
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, DirectCast(Sub() element.Focus(), System.Threading.ThreadStart))
        End If
    End Sub

from:
http://stackoverflow.com/questions/3865370/unable-to-set-focus-on-controls-inside-tab-control-in-wpf

Open in new window

0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40409232
Have you added a reference to WindowBase.dll?

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher(v=vs.110).aspx

To add the reference:
1.  Right-click on your project and select 'Add Reference'Capture.JPG2.  Select the .NET tab.Capture.JPG3.  Locate and select 'WindowsBase'Capture.JPG4.  Press 'OK'.

Once you have the reference added then you may need to refer to Dispatcher by it's fully qualified name, e.g. -
System.Windows.Threading.Dispatcher.BeginInvoke(...)

Open in new window

Or you can add an Imports statement to the top of your code file, e.g. -
Imports System.Windows.Threading

Public Class SomeClass
...
...
End Class

Open in new window


-saige-
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 40409254
Thank you.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question