Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:36:46+00:00 2026-05-23T13:36:46+00:00

I have a DataGrid in SL4 with a simple DataGridTextColumn columns. I’ve tried a

  • 0

I have a DataGrid in SL4 with a simple DataGridTextColumn columns.

I’ve tried a number of different methods to select all the text in a DataGridCell as soon as the cell changes to an editable TextBox.

The code below was my last attempt.

Inspecting the TextBox in debug shows that the SelectedText property is equal to the Text property. So the problem isn’t the TextBox. It seems something is deselecting the text later on.

public void PreparingCellForEdit(DataGridPreparingCellForEditEventArgs e)
    {
        var textBox = e.EditingElement as TextBox;
        if (textBox != null && !string.IsNullOrEmpty(textBox.Text))
        {
            textBox.GotFocus += (s, e2) =>
                {
                    {
                        textBox.SelectAll();
                    }
                };
        }
    }

Any ideas how to keep the text selected and display the TextBox with the selected text to the user?

P.S. I am using Cliburn.Micro to attach the PreparingCellForEdit event.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:36:47+00:00Added an answer on May 23, 2026 at 1:36 pm

    Somewhat of solution is to force focus to the TextBox after attaching to the GotFocus event.

    Like this:

        public void PreparingCellForEdit(DataGridPreparingCellForEditEventArgs e)
        {
            var textBox = e.EditingElement as TextBox;
            if (textBox != null)
            {
                textBox.GotFocus += (s, e2) => textBox.SelectAll();
                textBox.Focus();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have DataGrid with dataBinding: <sdk:DataGrid x:Name=colorGrid Height=160 Margin=0,5,0,10 RowHeight=40 AutoGenerateColumns=False > <sdk:DataGrid.Columns> <sdk:DataGridTextColumn
Trying to implement a simple print in SL4. I have a DataGrid that I
I have a DataGrid with 5 template columns, However when I try and add
I have a DataGrid bound to a DataView which, among other columns has, an
I have datagrid and noticed strange bug: I set HeadersVisibility=All. And when move mouse
I have datagrid and inside this grid have template field. I add Header text
I have a datagrid that allows user to change and save columns widths and
i have datagrid with 5 columns in it. and i write some data to
I have DataGrid with explicitly created columns in code. I am binding WPF element
i have datagrid(see bellow) there is columns with date time how i can make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.