Click here to Skip to main content
15,920,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: referencing a control from a string [modified] Pin
Jimmanuel19-May-09 9:46
Jimmanuel19-May-09 9:46 
GeneralRe: referencing a control from a string Pin
Tom Wright19-May-09 10:25
Tom Wright19-May-09 10:25 
GeneralRe: referencing a control from a string Pin
Tom Wright19-May-09 10:27
Tom Wright19-May-09 10:27 
GeneralRe: referencing a control from a string Pin
Jimmanuel19-May-09 10:38
Jimmanuel19-May-09 10:38 
GeneralRe: referencing a control from a string Pin
Tom Wright19-May-09 10:40
Tom Wright19-May-09 10:40 
GeneralRe: referencing a control from a string Pin
Jimmanuel19-May-09 11:00
Jimmanuel19-May-09 11:00 
GeneralRe: referencing a control from a string Pin
Jimmanuel19-May-09 11:17
Jimmanuel19-May-09 11:17 
AnswerRe: referencing a control from a string [modified] Pin
xcorporation19-May-09 11:05
xcorporation19-May-09 11:05 
private void Form1_Load(object sender, EventArgs e)
   {
     for (int x = 0; x < this.Controls.Count; ++x)
     {
      for (int y = 0; y < this.Controls[x].Controls.Count; ++y)
      {
        if (this.Controls[x].Controls[y].GetType() == typeof(RadioButton))
        {
         RadioButton _rdbtn = (RadioButton)this.Controls[x].Controls[y];
         _rdbtn.CheckedChanged += new EventHandler(_rdbtn_CheckedChanged);
        }
      }
     }
   }

   void _rdbtn_CheckedChanged(object sender, EventArgs e)
   {
     for (int x = 0; x < this.Controls.Count; ++x)
     {
      for (int y = 0; y < this.Controls[x].Controls.Count; ++y)
      {
        if (this.Controls[x].Controls[y].GetType() == typeof(RadioButton))
        {
         // Founded the radio button
         RadioButton _rdbtn = (RadioButton)this.Controls[x].Controls[y];

         if (_rdbtn.Checked == true)
         {
           for (int z = 0; z < this.Controls[x].Controls.Count; ++z)
           {
            if (this.Controls[x].Controls[z].GetType() == typeof(PictureBox))
            {
              // Change to green

              PictureBox _pic = (PictureBox)this.Controls[x].Controls[z];

              if (_pic.Tag == "Hi")
              {
               // this is the one you want to work with...

              }
            }
           }
         }
        }
      }
     }
   }


Take note...


if (rb.Checked && rb.Text.Contains("Run"))
{
OnLoadPictureImage(rb.Tag.ToString(), radioButton1.Checked);
}
else
{
OnLoadPictureImage(rb.Tag.ToString(), radioButton1.Checked);
}

will always execute irrelevant true or false.
i assume one is 'Unchecked'


This code should help only if you have the radio / image / etc. on panels.

remove the 2nd layer of loops if you not using panels...

Regards,
X


Yeee Cool | :cool:

modified on Tuesday, May 19, 2009 5:17 PM

GeneralRe: referencing a control from a string Pin
Tom Wright20-May-09 8:45
Tom Wright20-May-09 8:45 
QuestionRegex question Pin
Harvey Saayman19-May-09 8:46
Harvey Saayman19-May-09 8:46 
AnswerRe: Regex question Pin
led mike19-May-09 8:54
led mike19-May-09 8:54 
AnswerRe: Regex question Pin
Noctris19-May-09 8:56
Noctris19-May-09 8:56 
QuestionColor Convertor Pin
Rafone19-May-09 8:34
Rafone19-May-09 8:34 
AnswerRe: Color Convertor Pin
led mike19-May-09 8:50
led mike19-May-09 8:50 
QuestionComboBox AutoComplete with id value Pin
Noctris19-May-09 6:28
Noctris19-May-09 6:28 
AnswerRe: ComboBox AutoComplete with id value Pin
musefan19-May-09 6:42
musefan19-May-09 6:42 
GeneralRe: ComboBox AutoComplete with id value Pin
Noctris19-May-09 7:06
Noctris19-May-09 7:06 
AnswerRe: ComboBox AutoComplete with id value Pin
Noctris19-May-09 9:37
Noctris19-May-09 9:37 
QuestionToolstrip font combobox Pin
malcomhfc19-May-09 5:01
malcomhfc19-May-09 5:01 
AnswerRe: Toolstrip font combobox Pin
0x3c019-May-09 5:13
0x3c019-May-09 5:13 
GeneralRe: Toolstrip font combobox Pin
malcomhfc19-May-09 5:21
malcomhfc19-May-09 5:21 
GeneralRe: Toolstrip font combobox Pin
0x3c019-May-09 5:40
0x3c019-May-09 5:40 
GeneralRe: Toolstrip font combobox [modified] Pin
malcomhfc19-May-09 5:44
malcomhfc19-May-09 5:44 
GeneralRe: Toolstrip font combobox Pin
musefan19-May-09 6:16
musefan19-May-09 6:16 
GeneralRe: Toolstrip font combobox Pin
musefan19-May-09 6:36
musefan19-May-09 6:36 

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.