Click here to Skip to main content
15,911,139 members
Home / Discussions / C#
   

C#

 
AnswerRe: Umm...wow...request from one of our IBM guys - He needs to send an EBCDIC blob(not converted to ASCII) to be consumed directly by a C# app Pin
Moreno Airoldi20-May-09 1:05
Moreno Airoldi20-May-09 1:05 
QuestionWeb file download from C# console application gets 401 Pin
Mike Devenney19-May-09 9:22
Mike Devenney19-May-09 9:22 
AnswerRe: Web file download from C# console application gets 401 Pin
led mike19-May-09 10:13
led mike19-May-09 10:13 
AnswerRe: Web file download from C# console application gets 401 Pin
Noctris19-May-09 10:25
Noctris19-May-09 10:25 
GeneralRe: Web file download from C# console application gets 401 Pin
Baeltazor19-May-09 17:23
Baeltazor19-May-09 17:23 
GeneralRe: Web file download from C# console application gets 401 Pin
Mike Devenney20-May-09 5:04
Mike Devenney20-May-09 5:04 
QuestionRe: Web file download from C# console application gets 401 Pin
Mike Devenney20-May-09 7:21
Mike Devenney20-May-09 7:21 
Questionreferencing a control from a string Pin
Tom Wright19-May-09 9:17
Tom Wright19-May-09 9:17 
I have a number of PictureBox controls that show a Street Stop Light. Each Picturebox control is controled by two radio buttons for a total of 8 picturebox control and 16 radio buttons. One for Run (turns the Stop Light Green) One for Stop (turns the light red). I am storing the name of the PictureBox control in the tag of it respective radio buttons. Can I take this string and use it to reference the Picturebox control and change the image?

Here is me code:
private void OnCheckedChange(object sender, EventArgs e)
{
    RadioButton rb = (RadioButton)sender;
    if (rb.Checked && rb.Text.Contains("Run"))
    {
        OnLoadPictureImage(rb.Tag.ToString(), radioButton1.Checked);
    }
    else
    {
        OnLoadPictureImage(rb.Tag.ToString(), radioButton1.Checked);
    }
}

private void OnLoadPictureImage(String picBox, Boolean ObjectStatus)
{
    try
    {
        PictureBox pb = new PictureBox();
        pb = (PictureBox)this.Controls[picBox];
        if (ObjectStatus)
        {
            Stream s = File.Open("../images/traffic-light-green.jpg", FileMode.Open);
            Image temp = Image.FromStream(s);
            s.Close();
            pb.Image = temp;
        }
        else
        {
            Stream s = File.Open("../images/traffic-light-red.jpg", FileMode.Open);
            Image temp = Image.FromStream(s);
            s.Close();
            pb.Image = temp;
        }
    }
    catch (Exception err)
    {
        MessageBox.Show("Error finding image: " + err.Message);
    }
}

Is this not possible?

Thanks
Tom

Tom Wright
tawright915@gmail.com

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 
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 

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.