Click here to Skip to main content
15,881,776 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# search for specific folder in directory Pin
Ravi Bhavnani7-Oct-12 15:36
professionalRavi Bhavnani7-Oct-12 15:36 
Questioninvoke DoubleClick event Pin
Jassim Rahma7-Oct-12 9:03
Jassim Rahma7-Oct-12 9:03 
AnswerRe: invoke DoubleClick event Pin
JF20157-Oct-12 9:12
JF20157-Oct-12 9:12 
GeneralRe: invoke DoubleClick event Pin
BobJanova9-Oct-12 0:07
BobJanova9-Oct-12 0:07 
QuestionC# linq with 3 tables Pin
sc steinhayse7-Oct-12 7:56
sc steinhayse7-Oct-12 7:56 
AnswerRe: C# linq with 3 tables Pin
Aasif Chanandin8-Oct-12 5:11
Aasif Chanandin8-Oct-12 5:11 
AnswerRe: C# linq with 3 tables Pin
gazmendmehmeti8-Oct-12 21:52
gazmendmehmeti8-Oct-12 21:52 
QuestionWhy is my control added three times? Pin
GrooverFromHolland7-Oct-12 7:01
GrooverFromHolland7-Oct-12 7:01 
Hi all,

In my windows form I have many group-boxes with text-boxes.
I am changing the back color of the text-boxes whenever a text-box has or looses focus.
This works OK.
I also want to add a help button in the group-box when a text-box in this group-box has focus,
but my help button is added three times?
This is the code I use:

private void control_Settings()
      {
          Button buttonHelp = new Button();
          buttonHelp.BackColor = System.Drawing.Color.Transparent;
          buttonHelp.Image = Properties.Resources.HelpButtonImage;
          buttonHelp.Dock = DockStyle.Right;    // only for testing.
          buttonHelp.Name = "buttonHelp";
          buttonHelp.Size = new System.Drawing.Size(25, 25);
          buttonHelp.UseVisualStyleBackColor = false;
          buttonHelp.Click += new System.EventHandler(this.buttonHelp_Click);

          foreach (Control gb in Controls)
          {
              if (gb is GroupBox)
              {
                  GroupBox grpbx = (GroupBox)gb;

                  foreach (Control t in grpbx.Controls)
                  {
                      TextBox textBox = t as TextBox;


                      if (textBox != null)
                      {

                          textBox.Enter += delegate(object sender, EventArgs eventArgs)
                                       {
                                           ((TextBox)sender).BackColor = Color.Gold;

                                           Control pToAd = ((TextBox)sender).Parent;
                                              if(!pToAd.Controls.Contains(buttonHelp))pToAd.Controls.Add(buttonHelp);
                                       };
                          textBox.Leave += delegate(object sender, EventArgs eventArgs)
                          {
                              Control pToRemove = ((TextBox)sender).Parent;
                              ((TextBox)sender).BackColor = Color.White;
                              pToRemove.Controls.Remove(buttonHelp);
                          };
                      }
                  }

               }
          }
      }


Thanks in advance,

Groover
0200 A9 23
0202 8D 01 80
0205 00

AnswerRe: Why is my control added three times? Pin
DaveyM697-Oct-12 8:09
professionalDaveyM697-Oct-12 8:09 
GeneralRe: Why is my control added three times? Pin
GrooverFromHolland7-Oct-12 8:42
GrooverFromHolland7-Oct-12 8:42 
GeneralRe: Why is my control added three times? Pin
DaveyM697-Oct-12 9:01
professionalDaveyM697-Oct-12 9:01 
AnswerRe: Why is my control added three times? Pin
Alan N7-Oct-12 8:34
Alan N7-Oct-12 8:34 
GeneralRe: Why is my control added three times? Pin
DaveyM697-Oct-12 9:02
professionalDaveyM697-Oct-12 9:02 
GeneralRe: Why is my control added three times? Pin
GrooverFromHolland7-Oct-12 10:23
GrooverFromHolland7-Oct-12 10:23 
AnswerRe: Why is my control added three times? Pin
V.7-Oct-12 23:41
professionalV.7-Oct-12 23:41 
QuestionHow FingerPrint Device uses zkemkeeper.dll to get ID of each user print it's finger in Device Pin
osama_hagrass6-Oct-12 23:13
osama_hagrass6-Oct-12 23:13 
AnswerRe: How FingerPrint Device uses zkemkeeper.dll to get ID of each user print it's finger in Device Pin
Eddy Vluggen7-Oct-12 1:14
professionalEddy Vluggen7-Oct-12 1:14 
QuestionC# string array Pin
sc steinhayse6-Oct-12 15:11
sc steinhayse6-Oct-12 15:11 
AnswerRe: C# string array Pin
Dave Kreskowiak6-Oct-12 20:26
mveDave Kreskowiak6-Oct-12 20:26 
AnswerRe: C# string array Pin
Eddy Vluggen7-Oct-12 1:13
professionalEddy Vluggen7-Oct-12 1:13 
AnswerRe: C# string array Pin
montevina 28-Oct-12 1:30
montevina 28-Oct-12 1:30 
GeneralRe: C# string array Pin
BobJanova9-Oct-12 0:09
BobJanova9-Oct-12 0:09 
AnswerRe: C# string array Pin
BobJanova9-Oct-12 0:10
BobJanova9-Oct-12 0:10 
Questionwindows service to check file directory path Pin
rachel_m6-Oct-12 9:46
rachel_m6-Oct-12 9:46 
AnswerRe: windows service to check file directory path Pin
Richard Andrew x646-Oct-12 9:56
professionalRichard Andrew x646-Oct-12 9:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.