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

  • SEARCH
  • Home
  • 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 8847947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:18:42+00:00 2026-06-14T12:18:42+00:00

I have several lists of text boxes on a form each representing a column

  • 0

I have several lists of text boxes on a form each representing a column of a database. I want to update the form each time the user exits one of the boxes for price. the name of this list is priceBox[]. I am aware of the lostFocus event but I cant seem to figure a way to get it to work for a collection and this list can grow so I cant have a fixed number. I dont have any code for this yet. if it helps the text box controls are contained in a panel named panel1.

I have tried searching and cant find anything on this. only for singular instances, like updating 1 text box.

sorry if this is a duplicate but I did try to search. also I am new to c#.

thanks.

  • 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-14T12:18:43+00:00Added an answer on June 14, 2026 at 12:18 pm

    One approach is adding a ControlAdded handler to the panel, so every time a new textbox is added, it automatically adds LostFocus handler for it. Step-by-step below:

    For your panel you bind a handler ControlAdded event, which would be something like:

    private void Panel1_ControlAdded(object sender, ControlEventArgs e)
    {
        var tb = e.Control as TextBox;
        if (tb != null)
        {
            tb.LostFocus += new EventHandler(TextBox_LostFocus);
        }
    }
    

    Then in TextBox_LostFocus you can add whatever logic you want

    void TextBox_LostFocus(object sender, EventArgs e)
    {
        var tb = sender as TextBox;
        if (tb != null)
        {
            // modify tb.Text here, possibly like this...
            tb.Text = String.Format("{0:C}", Decimal.Parse(tb.Text));
        }
    }
    

    To update all existing controls (not tested)

    foreach (TextBox in panel1.Controls)
    {
        tb.LostFocus += new EventHandler(TextBox_LostFocus);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF User Control with a UIElement Grid with several text boxes
I have a form containing several drop lists and a text field, and a
The situation: I have several lists; in each of these lists, the text inside
I have several lists in Matlab that I want to write to the same
I have several different lists I want to call. They all have the same
I have several unordered lists that I want to display like this: <ul> <li><img></li>
I have several hundred files in a non-flat directory structure. My Makefile lists each
I have a site that lists several upcoming events, and each event has a
I have several definition lists each containing a nested ordered list and anchor. On
I have several markers on my google map. Each has text that should show

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.