Results 1 to 4 of 4

Thread: Problem with Set Focus in outlook

  1. #1
    Join Date
    Nov 2009
    Posts
    140

    Problem with Set Focus in outlook

    Hello there

    I am using the Outlook Style UI in coordination with main window i.e the tabbed windows in Visual Studio. I getting the problem with the setting Focus to UI elements in my program. I need the set focus for set keyboard focus to a UI element for user, Set focus for button, textbox as well as list box for the event generation and set up focus to a search panel for the search button. Help me if any one have the solution for the focusing issue. Waiting for the reply.


    Thank you

  2. #2
    Join Date
    Jan 2008
    Posts
    3,755

    Re: Problem with Set Focus in outlook

    Hey brother,

    As per your query discussed above i came to know that your problem is about the setting focus to the element of you program. For that i have a solution which i got form one the forum and posting that here. So that you can try this and changed it according to your program to take in action. Hope you like it

    Code:
    <UserControl x:Class="WpfApplication.Control"
    xmlns="Name of the site which you like"
    xmlns:x="Name of the site which you like"
    Height="400" Width="400">
    <StackPanel Name="Stack Panell">
    <TextBox Name="textbox1"/>
    <ListBox Name="lstbox">
    <ListBoxItem>Product 1</ListBoxItem>
    <ListBoxItem>Product 2</ListBoxItem>
    <ListBoxItem>Product 3</ListBoxItem>
    </ListBox>
    <Button Name="button1"  Content="Button"/>
    <Button Content="set focus" Click="button_Click"/>
    </StackPanel>
    </UserControl>
    
     public partial class Control : User Control
    {
     public Control()
     {
       InitializeComponent();
      }
     private void button_Click(object sender, RoutedEventArgs e)
    { this.txtbox.Focus();
       Keyboard.Focus(this.txtbox);
    }

  3. #3
    Join Date
    Apr 2008
    Posts
    2,139

    Re: Problem with Set Focus in outlook

    Set Focus method Moves the focus to this instance of an object.
    Syntax: object.SetFocus

    If setting the focus fails, the focus reverts to the previous object and an error is generated.By default, setting the focus to a control does not activate the control's window or place it on top of other controls. The SetFocus method is valid for an empty Frame as well as a Frame that contains other controls. An empty Frame will take the focus itself, and any subsequent keyboard events apply to the Frame. In a Frame that contains other controls, the focus moves to the first control in the Frame, and subsequent keyboard events apply to the control that has the focus.

    To know more click here

  4. #4
    Join Date
    Apr 2008
    Posts
    4,642

    Re: Problem with Set Focus in outlook

    Hi,

    Even i have something to share with hope that it will help regarding your issue. The below given code might be helpful for you to set the focus to the window. The above post is incomplete without this code so use this code with the above one and see whether it is working or not.
    Code:
    <Window x:Class="WpfApplication.Window"
    xmlns="Site name which you used above"
    xmlns:x="Site name which you used above"
    xmlns:local="clr-namespace:WpfApplication1"
    Title="Window" Name="window">
    <local:UserControl/>
    </Window>

Similar Threads

  1. Replies: 5
    Last Post: 30-09-2011, 12:09 PM
  2. Replies: 7
    Last Post: 12-09-2011, 10:48 PM
  3. Focus problem with canon SD 850 IS
    By Ektoras in forum Portable Devices
    Replies: 4
    Last Post: 06-03-2011, 03:42 AM
  4. Lost focus problem with Media player classic under Windows 7
    By Graciano in forum Windows Software
    Replies: 5
    Last Post: 21-01-2010, 01:57 AM
  5. Focus Problem with Sony projecter
    By Eagle Eye in forum Portable Devices
    Replies: 3
    Last Post: 07-08-2009, 04:42 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,554,673.52580 seconds with 17 queries