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 8188295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:51:37+00:00 2026-06-07T02:51:37+00:00

public partial class Backspace : Window { Control TextBoxDetails; TextBox BehaveTextbox; public Backspace() {

  • 0
public partial class Backspace : Window
{
    Control TextBoxDetails;
    TextBox BehaveTextbox;
    public Backspace()
    {
        this.InitializeComponent();

        // Insert code required on object creation below this point.
    }

    private void btn_t_Click(object sender, RoutedEventArgs e)
    {
        BehaveTextbox = TextBoxDetails as TextBox;
        if (TextBoxDetails != null)
        {
            var _CareIndex = BehaveTextbox.CaretIndex;
            BehaveTextbox.Text = BehaveTextbox.Text.Insert(_CareIndex, "      ");
            BehaveTextbox.Focus();
            BehaveTextbox.CaretIndex = _CareIndex + 6;
        }
    }

    private void btn_s_Click(object sender, RoutedEventArgs e)
    {
        BehaveTextbox = TextBoxDetails as TextBox;
        if (TextBoxDetails != null)
        {
            var _CareIndex = BehaveTextbox.CaretIndex;
            BehaveTextbox.Text = BehaveTextbox.Text.Insert(_CareIndex, " ");
            BehaveTextbox.Focus();
            BehaveTextbox.CaretIndex = _CareIndex + 1;
        }
    }

    private void btn_bs_Click(object sender, RoutedEventArgs e)
    {
        BehaveTextbox = TextBoxDetails as TextBox;

        if (TextBoxDetails != null)
        {

            string _CurrentValue = BehaveTextbox.Text;
            var _CareIndex = BehaveTextbox.CaretIndex;

            if (_CareIndex > 0)
            {
                string _Backspace = _CurrentValue.Remove(_CareIndex - 1, 1);
                BehaveTextbox.Text = _Backspace;
                BehaveTextbox.Focus();
                BehaveTextbox.CaretIndex = _CareIndex - 1;
            }
        }
    }

    private void txt_result_GotFocus(object sender, RoutedEventArgs e)
    {
        TextBoxDetails = (Control)sender;
    }
}

Design

in above figure textbox has some text value.I put 3 spaces between 111 and 222 by clicking SPACE button(btn_s)3 time,Then put 2 tab between 222 and 333 by clicking TAB button(btn_t) 2 time.

When I click the Backspace button(btn_bs), each time only one space or letter will clear.But what i want to do is, when click Backspace button(btn_bs), if there is tabed in text box, That should remove. If there is spaced in textbox, That would remove.

  • 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-06-07T02:51:39+00:00Added an answer on June 7, 2026 at 2:51 am

    Try this:

    public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            Control TextBoxDetails;
            TextBox BehaveTextbox;
    
            private void btn_t_Click(object sender, RoutedEventArgs e)
            {
                BehaveTextbox = TextBoxDetails as TextBox;
                if (TextBoxDetails != null)
                {
                    var _CareIndex = BehaveTextbox.CaretIndex;
                    BehaveTextbox.Text = BehaveTextbox.Text.Insert(_CareIndex, "\t");
                    BehaveTextbox.Focus();
                    BehaveTextbox.CaretIndex = _CareIndex + 1;
                }
            }
    
            private void btn_s_Click(object sender, RoutedEventArgs e)
            {
                BehaveTextbox = TextBoxDetails as TextBox;
                if (TextBoxDetails != null)
                {
                    var _CareIndex = BehaveTextbox.CaretIndex;
                    BehaveTextbox.Text = BehaveTextbox.Text.Insert(_CareIndex, " ");
                    BehaveTextbox.Focus();
                    BehaveTextbox.CaretIndex = _CareIndex + 1;
                }
            }
    
            private void btn_bs_Click(object sender, RoutedEventArgs e)
            {
                BehaveTextbox = TextBoxDetails as TextBox;
    
                if (TextBoxDetails != null)
                {
    
                    string _CurrentValue = BehaveTextbox.Text;
                    var _CareIndex = BehaveTextbox.CaretIndex;
    
                    if (_CareIndex > 0)
                    {
                        string _Backspace = _CurrentValue.Remove(_CareIndex - 1, 1);
                        BehaveTextbox.Text = _Backspace;
                        BehaveTextbox.Focus();
                        BehaveTextbox.CaretIndex = _CareIndex - 1;
                    }
                }
            }
    
            private void txt_result_GotFocus(object sender, RoutedEventArgs e)
            {
                TextBoxDetails = (Control)sender;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); SerialPort MySerialPort =
Here is my code: public partial class Image : System.Web.UI.Page { protected void Page_Load(object
With this code: public partial class Form1 : Form { private static readonly int
say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock
I have following code public partial class MainWindow : Window { public MainWindow() {
I have this class: public partial class Window1 : Window { public String Name2;
I have this C# code: public partial class Continue : Form { public Continue(string
public partial class PreTextBox : TextBox { public PreTextBox() { InitializeComponent(); Text = PreText;
I have this code: public partial class App : Application { protected override void
I have this c# user control class: public partial class UserControls_JsTop : System.Web.UI.UserControl {

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.