Click here to Skip to main content
15,905,414 members
Home / Discussions / C#
   

C#

 
QuestionHow to retrieve Image from access Database Pin
eng.mohamed26-May-05 5:55
eng.mohamed26-May-05 5:55 
AnswerRe: How to retrieve Image from access Database Pin
Judah Gabriel Himango26-May-05 9:13
sponsorJudah Gabriel Himango26-May-05 9:13 
GeneralOdbcDataReader!! Pin
trk_wakil26-May-05 5:04
trk_wakil26-May-05 5:04 
GeneralRe: OdbcDataReader!! Pin
pubududilena26-May-05 19:34
pubududilena26-May-05 19:34 
Generalsocket handling Pin
cyrus10926-May-05 4:49
cyrus10926-May-05 4:49 
GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 5:06
S. Senthil Kumar26-May-05 5:06 
GeneralRe: socket handling Pin
cyrus10926-May-05 5:12
cyrus10926-May-05 5:12 
GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 6:19
S. Senthil Kumar26-May-05 6:19 
GeneralRe: socket handling Pin
cyrus10926-May-05 10:17
cyrus10926-May-05 10:17 
GeneralHandling Win32 logical palette's in C# Pin
Rahsas26-May-05 3:41
Rahsas26-May-05 3:41 
GeneralWord automation selecting tray Pin
Master_Blaster26-May-05 3:05
Master_Blaster26-May-05 3:05 
GeneralRemoting Q. Pin
Member 199247026-May-05 1:06
Member 199247026-May-05 1:06 
GeneralRe: Remoting Q. Pin
S. Senthil Kumar26-May-05 2:59
S. Senthil Kumar26-May-05 2:59 
GeneralRe: Remoting Q. Pin
Member 199247026-May-05 4:42
Member 199247026-May-05 4:42 
GeneralImplementation in C# Pin
Diego12326-May-05 0:52
Diego12326-May-05 0:52 
GeneralRe: Implementation in C# Pin
Marc Clifton26-May-05 1:04
mvaMarc Clifton26-May-05 1:04 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 1:49
Colin Angus Mackay26-May-05 1:49 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 2:55
S. Senthil Kumar26-May-05 2:55 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 3:16
Colin Angus Mackay26-May-05 3:16 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 4:24
S. Senthil Kumar26-May-05 4:24 
GeneralWhy toolbar buttons doesn't care of CausesValidation Pin
Itanium26-May-05 0:38
Itanium26-May-05 0:38 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos26-May-05 5:12
Luis Alonso Ramos26-May-05 5:12 
I ran into this problem sometime ago. I have several MDI children, each with a toolbar. So I added this routine to the base class, and call it as the first thing on th ButtonClick handler for the toolbar.
/// <summary>
/// Causes the validation events for the current focused control, without
/// it losing it.
/// </summary>
/// <remarks>Walks recursively through all the form's controls to find
/// the one that currently has the focus.</remarks>
protected void ValidateFocusedControl()
{
    foreach(Control ctl in Controls)
        if(ValidateFocusedControlRecursive(ctl))
            break;
}

/// <summary>
/// Helper function for ValidateFocusedControl.  Walks recursively the
/// children of the Control passed as a parameter.
/// </summary>
/// <param name="ctl">Control to walk its children.</param>
/// <returns>True if the focused control was found, false to keep
/// searching</returns>
/// <remarks>If the focused control is found, a new text box is created,
/// the focus set to it, and then back to focused control.</remarks>
bool ValidateFocusedControlRecursive(Control ctl)
{
    if(ctl.Focused)
    {
        if(ctl.CausesValidation)
        {
            // Make current focused control lose focus, and then get
            // it back, so we can force its validation
            TextBox txtBox = new TextBox();
            txtBox.Bounds = new Rectangle(-100, -100, 1, 1);
            txtBox.Parent = ctl.Parent;
            txtBox.Focus();
            ctl.Focus();
            txtBox.Parent = null;
            txtBox.Dispose();
        }
        return true;
    }

    // Walk children
    foreach(Control ctl2 in ctl.Controls)
        if(ValidateFocusedControlRecursive(ctl2))
            return true;

    return false;
}
It basically finds which is the focused control, creates a new TextBox, gives it focus, and sets focus back to the original control.

Good luck!

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos26-May-05 5:13
Luis Alonso Ramos26-May-05 5:13 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Itanium31-May-05 22:42
Itanium31-May-05 22:42 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos1-Jun-05 6:01
Luis Alonso Ramos1-Jun-05 6:01 

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.