Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Icon in a textbox

Icon in a textbox

Scheduled Pinned Locked Moved C#
sysadmin
8 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    edlanka
    wrote on last edited by
    #1

    I have a type ahead textbox and on each key press I post back to the server. while the textbox is waiting for the results I would like to display a spinner icon next to the text in the textbox. this spinner icon would indicate that the textbox is waiting for the results. I have looked at various properties of the text box and couldn’t any property which would allow me to do that. any suggestions would be appreciated.. thanks, kar

    I 1 Reply Last reply
    0
    • E edlanka

      I have a type ahead textbox and on each key press I post back to the server. while the textbox is waiting for the results I would like to display a spinner icon next to the text in the textbox. this spinner icon would indicate that the textbox is waiting for the results. I have looked at various properties of the text box and couldn’t any property which would allow me to do that. any suggestions would be appreciated.. thanks, kar

      I Offline
      I Offline
      Ian McCaul
      wrote on last edited by
      #2

      I would recommend you look at the AJAX tool kit and use an update panel with an update progress control and respond to the textbox.textchanged event. You may have to set auto postback to true on it as well. This article may help for the AJAX peice. The UpdateProgress Control of ASP.NET AJAX Extensions[^] Hope this helps.

      E 1 Reply Last reply
      0
      • I Ian McCaul

        I would recommend you look at the AJAX tool kit and use an update panel with an update progress control and respond to the textbox.textchanged event. You may have to set auto postback to true on it as well. This article may help for the AJAX peice. The UpdateProgress Control of ASP.NET AJAX Extensions[^] Hope this helps.

        E Offline
        E Offline
        edlanka
        wrote on last edited by
        #3

        Thanks for the info.. The Text box i wam working on is Winforms textbox. Is there a similar thing that works in a Winforms environment.. Thanks kar

        I 1 Reply Last reply
        0
        • E edlanka

          Thanks for the info.. The Text box i wam working on is Winforms textbox. Is there a similar thing that works in a Winforms environment.. Thanks kar

          I Offline
          I Offline
          Ian McCaul
          wrote on last edited by
          #4

          Oh I thought you were using ASP.NET since you were sending back to server (what I get for assuming)... You can still respond to the TextBox.TextChanged event. This fires after any input into the textbox. You can use an animated gif to put into an image control to be visible while you are performing whatever operation during the event and set it to visible = false when your processing is complete.

          private void currencyTextBox_TextChanged(object sender, EventArgs e)
          {
          imageProgress.Visible = true;
          Application.DoEvents();

          ... // Processing
          
          imageProgress.Visible = false;
          Application.DoEvents();
          

          }

          You may have an issue with setting the visiblilty in the current thread... the Application.DoEvents() may solve that, but may not, you may need to look at doing the proccessing on a different thread, you could use a backgroundworker for doing that and it is fairly easy to implement. Hope this helps.

          E 1 Reply Last reply
          0
          • I Ian McCaul

            Oh I thought you were using ASP.NET since you were sending back to server (what I get for assuming)... You can still respond to the TextBox.TextChanged event. This fires after any input into the textbox. You can use an animated gif to put into an image control to be visible while you are performing whatever operation during the event and set it to visible = false when your processing is complete.

            private void currencyTextBox_TextChanged(object sender, EventArgs e)
            {
            imageProgress.Visible = true;
            Application.DoEvents();

            ... // Processing
            
            imageProgress.Visible = false;
            Application.DoEvents();
            

            }

            You may have an issue with setting the visiblilty in the current thread... the Application.DoEvents() may solve that, but may not, you may need to look at doing the proccessing on a different thread, you could use a backgroundworker for doing that and it is fairly easy to implement. Hope this helps.

            E Offline
            E Offline
            edlanka
            wrote on last edited by
            #5

            This one helps.. but the imagecontrol is seperate from the textbox. In my scenario the image control is inside the textbox. more specifically on the right most side of the textbox where its spinning while waiting for the results to come back.. Could u let me know how I could tie up the image control inside the textbox. Thanks, kar

            M D N 3 Replies Last reply
            0
            • E edlanka

              This one helps.. but the imagecontrol is seperate from the textbox. In my scenario the image control is inside the textbox. more specifically on the right most side of the textbox where its spinning while waiting for the results to come back.. Could u let me know how I could tie up the image control inside the textbox. Thanks, kar

              M Offline
              M Offline
              Mbah Dhaim
              wrote on last edited by
              #6

              try using your own user control that contains textbox and image control, add event begin and end progress to trigger visibility of your image control hope it helps

              dhaim ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro" in the front line gave a lead, in the middle line build goodwill, in the behind give power support

              1 Reply Last reply
              0
              • E edlanka

                This one helps.. but the imagecontrol is seperate from the textbox. In my scenario the image control is inside the textbox. more specifically on the right most side of the textbox where its spinning while waiting for the results to come back.. Could u let me know how I could tie up the image control inside the textbox. Thanks, kar

                D Offline
                D Offline
                DaveyM69
                wrote on last edited by
                #7

                You could do something like this. Not perfect or complete but should be a start.

                using System;
                using System.ComponentModel;
                using System.Drawing;
                using System.Windows.Forms;

                public class BusyTextBox : TextBox
                {
                private Image busyImage;
                private bool isBusy;

                public Image BusyImage
                {
                    get { return busyImage; }
                    set { busyImage = value; }
                }
                
                \[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
                Browsable(false)\]
                public bool IsBusy
                {
                    get { return isBusy; }
                    private set
                    {
                        isBusy = value;
                        if (value)
                        {
                            using (Graphics g = this.CreateGraphics())
                            {
                                // draw image
                                // g.DrawImage(busyImage,
                            }
                        }
                        else
                        {
                            Invalidate();
                        }
                    }
                }
                
                protected override void OnTextChanged(EventArgs e)
                {
                    IsBusy = true;
                    // Do Your DB Stuff
                    base.OnTextChanged(e);
                    IsBusy = false;
                }
                

                }

                Make sure you dispose of the busyImage if not null when the BusyTextBox is disposed!

                Dave
                BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
                Why are you using VB6? Do you hate yourself? (Christian Graus)

                1 Reply Last reply
                0
                • E edlanka

                  This one helps.. but the imagecontrol is seperate from the textbox. In my scenario the image control is inside the textbox. more specifically on the right most side of the textbox where its spinning while waiting for the results to come back.. Could u let me know how I could tie up the image control inside the textbox. Thanks, kar

                  N Offline
                  N Offline
                  Naruki 0
                  wrote on last edited by
                  #8

                  You mean something like the ErrorControl? You might be able to wrangle that functionality to do what you want.

                  Codemonkeys don't do it at all. Too busy coding.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups