views:

360

answers:

1

I have Windows Mobile 6.0 application. I have ImageButton control given by Microsoft.

I want my ImageButton control to have focus border like any standard button. How I can do it?

Thanks in advice!

+1  A: 

I want to suggest the answer after some manipulations with code.

The trick is to check whether the control is focused in OnPaint method and draw transparent or black border:

gxOff.DrawRectangle(new Pen((this.Focused) ? Color.Black : Color.Transparent), rc);

and call Invalidate() in OnGotFocus and OnLostFocus events:

protected override void OnGotFocus(EventArgs 
{
    base.OnGotFocus(e);
    this.Invalidate();
}

protected override void OnLostFocus(EventArgs e)
{
    base.OnLostFocus(e);
    this.Invalidate();
}

Hope it will help somebody :)

sashaeve