Click here to Skip to main content
15,899,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: win6x_registry_tweak Pin
Gregan Dark23-Oct-17 9:23
Gregan Dark23-Oct-17 9:23 
GeneralRe: win6x_registry_tweak Pin
Dave Kreskowiak23-Oct-17 9:48
mveDave Kreskowiak23-Oct-17 9:48 
GeneralRe: win6x_registry_tweak Pin
Pete O'Hanlon23-Oct-17 9:55
mvePete O'Hanlon23-Oct-17 9:55 
GeneralRe: win6x_registry_tweak Pin
Dave Kreskowiak24-Oct-17 2:56
mveDave Kreskowiak24-Oct-17 2:56 
GeneralRe: win6x_registry_tweak Pin
Pete O'Hanlon23-Oct-17 9:49
mvePete O'Hanlon23-Oct-17 9:49 
QuestionNewbie question - how to access this object Pin
Member 1347915022-Oct-17 13:10
Member 1347915022-Oct-17 13:10 
AnswerRe: Newbie question - how to access this object Pin
User 740747022-Oct-17 14:23
User 740747022-Oct-17 14:23 
AnswerRe: Newbie question - how to access this object Pin
OriginalGriff22-Oct-17 19:50
mveOriginalGriff22-Oct-17 19:50 
Since you derive your SomeClass from PictureBox, the best way is is to do it properly: create an event in your SomeClass which indicates to the outside world "I need attention".
Your panel handles that event, and changes itself.

That way, the control doesn't need to know about any containing controls, and the containing control becomes responsible for indicating the change itself:
public class SomeClass : PictureBox
    {
    public SomeClass()
        {
        this.BackColor = Color.Green;
        this.MouseDown += new System.Windows.Forms.MouseEventHandler(mouseDown);
        }
    public void mouseDown(object sender, MouseEventArgs e)
        {
        OnFocussed(e);
        }
    /// <summary>
    /// Event to indicate Focussed on
    /// </summary>
    public event EventHandler Focussed;
    /// <summary>
    /// Called to signal to subscribers that Focussed on
    /// </summary>
    /// <param name="e"></param>
    protected virtual void OnFocussed(EventArgs e)
        {
        EventHandler eh = Focussed;
        if (eh != null)
            {
            eh(this, e);
            }
        }
    }
And your Panel handles it:
    {
    MyPictureBox1.Focussed += MyPictureBox_Focussed;
    MyPictureBox2.Focussed += MyPictureBox_Focussed;
    MyPictureBox3.Focussed += MyPictureBox_Focussed;
    }

void MyPictureBox_Focussed(object sender, EventArgs e)
    {
    SomeClass sc = sender as SomeClass;
    if (sc != null)
        {
        BackColor = Color.Red;
        }
    }

Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: Newbie question - how to access this object Pin
BillWoodruff23-Oct-17 4:48
professionalBillWoodruff23-Oct-17 4:48 
GeneralMessage Closed Pin
23-Oct-17 5:51
User 740747023-Oct-17 5:51 
GeneralRe: Newbie question - how to access this object Pin
BillWoodruff24-Oct-17 3:46
professionalBillWoodruff24-Oct-17 3:46 
GeneralMessage Closed Pin
24-Oct-17 12:56
User 740747024-Oct-17 12:56 
GeneralRe: Newbie question - how to access this object Pin
Jim_Snyder27-Oct-17 4:56
professionalJim_Snyder27-Oct-17 4:56 
QuestionAnyone experiencing that, .NET Standard project in VS2017 hanging while compiling Pin
Super Lloyd22-Oct-17 9:42
Super Lloyd22-Oct-17 9:42 
AnswerRe: Anyone experiencing that, .NET Standard project in VS2017 hanging while compiling Pin
Richard MacCutchan22-Oct-17 11:20
mveRichard MacCutchan22-Oct-17 11:20 
QuestionRe: Anyone experiencing that, .NET Standard project in VS2017 hanging while compiling Pin
Super Lloyd22-Oct-17 12:28
Super Lloyd22-Oct-17 12:28 
AnswerRe: Anyone experiencing that, .NET Standard project in VS2017 hanging while compiling Pin
Richard MacCutchan22-Oct-17 20:52
mveRichard MacCutchan22-Oct-17 20:52 
AnswerRe: Anyone experiencing that, .NET Standard project in VS2017 hanging while compiling Pin
jschell23-Oct-17 7:34
jschell23-Oct-17 7:34 
QuestionHow to start a form without being activated? [solved] Pin
alin120-Oct-17 14:48
alin120-Oct-17 14:48 
AnswerRe: How to start a form without being activated? Pin
BillWoodruff20-Oct-17 16:30
professionalBillWoodruff20-Oct-17 16:30 
AnswerRe: How to start a form without being activated? Pin
OriginalGriff21-Oct-17 0:03
mveOriginalGriff21-Oct-17 0:03 
GeneralRe: How to start a form without being activated? Pin
BillWoodruff21-Oct-17 0:27
professionalBillWoodruff21-Oct-17 0:27 
GeneralRe: How to start a form without being activated? Pin
OriginalGriff21-Oct-17 0:41
mveOriginalGriff21-Oct-17 0:41 
GeneralRe: How to start a form without being activated? Pin
alin121-Oct-17 7:04
alin121-Oct-17 7:04 
GeneralRe: How to start a form without being activated? Pin
alin121-Oct-17 7:00
alin121-Oct-17 7:00 

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.