Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
AnswerRe: help in solving a problem Pin
Richard MacCutchan8-Oct-12 6:57
mveRichard MacCutchan8-Oct-12 6:57 
AnswerRe: help in solving a problem Pin
Dave Kreskowiak8-Oct-12 11:00
mveDave Kreskowiak8-Oct-12 11:00 
AnswerRe: help in solving a problem Pin
Abhinav S8-Oct-12 17:37
Abhinav S8-Oct-12 17:37 
AnswerRe: help in solving a problem Pin
Paul Conrad10-Oct-12 7:46
professionalPaul Conrad10-Oct-12 7:46 
QuestionUsing a datagridview to maintain SQL server database table Pin
Member 80860588-Oct-12 1:35
Member 80860588-Oct-12 1:35 
QuestionC# select part of file name Pin
classy_dog7-Oct-12 16:00
classy_dog7-Oct-12 16:00 
AnswerRe: C# select part of file name Pin
Abhinav S7-Oct-12 17:47
Abhinav S7-Oct-12 17:47 
AnswerRe: C# select part of file name Pin
Pete O'Hanlon7-Oct-12 20:17
mvePete O'Hanlon7-Oct-12 20:17 
QuestionC# search for specific folder in directory Pin
classy_dog7-Oct-12 10:19
classy_dog7-Oct-12 10:19 
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 
AnswerRe: Why is my control added three times? Pin
DaveyM697-Oct-12 8:09
professionalDaveyM697-Oct-12 8:09 
You must have something strange going on, I just copied your code into a blank winforms project and it worked perfectly.
(I changed some of the naming so I could understand the flow better)
C#
using System;
using System.Drawing;
using System.Windows.Forms;

public partial class FormMain : Form
{
    public Form1()
    {
        // Added two GroupBoxes both containing two Textboxes in designer
        InitializeComponent();
        ControlSettings();
    }
    private void ControlSettings()
    {
        Button buttonHelp = new Button();
        buttonHelp.BackColor = System.Drawing.Color.Transparent;
        buttonHelp.Dock = DockStyle.Right;    // only for testing.
        buttonHelp.Name = "buttonHelp";
        buttonHelp.Size = new System.Drawing.Size(25, 25);
        buttonHelp.UseVisualStyleBackColor = false;

        foreach (Control control in Controls)
        {
            if (control is GroupBox)
            {
                GroupBox groupBox = (GroupBox)control;
                foreach (Control nestedControl in groupBox.Controls)
                {
                    TextBox textBox = nestedControl as TextBox;
                    if (textBox != null)
                    {
                        textBox.Enter += delegate(object sender, EventArgs eventArgs)
                        {
                            ((TextBox)sender).BackColor = Color.Gold;
                            Control parent = ((TextBox)sender).Parent;
                            parent.Controls.Add(buttonHelp);
                        };
                        textBox.Leave += delegate(object sender, EventArgs eventArgs)
                        {
                            Control parent = ((TextBox)sender).Parent;
                            ((TextBox)sender).BackColor = Color.White;
                            parent.Controls.Remove(buttonHelp);
                        };
                    }
                }

            }
        }
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



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 

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.