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

C#

 
QuestionSingle Thread Problem.. Pin
ShimiG16-Oct-05 9:08
ShimiG16-Oct-05 9:08 
AnswerRe: Single Thread Problem.. Pin
Daniel Grunwald16-Oct-05 9:11
Daniel Grunwald16-Oct-05 9:11 
Questionwhile scrolling using autoscroll in a panel, the contents won't update until you stop scrolling (on some pc's) Pin
cornholios16-Oct-05 7:27
cornholios16-Oct-05 7:27 
AnswerRe: while scrolling using autoscroll in a panel, the contents won't update until you stop scrolling (on some pc's) Pin
cornholios17-Oct-05 0:01
cornholios17-Oct-05 0:01 
QuestionHow can i know when Windows open a file Pin
neuemvanlanhlung16-Oct-05 7:02
neuemvanlanhlung16-Oct-05 7:02 
AnswerRe: How can i know when Windows open a file Pin
Dave Kreskowiak16-Oct-05 9:17
mveDave Kreskowiak16-Oct-05 9:17 
QuestionRemoting: How can client X notify client Y via a server object by using events? Pin
buysjohan@hotmail.com16-Oct-05 5:21
buysjohan@hotmail.com16-Oct-05 5:21 
QuestionWhere to put my validation? Please help. Pin
CandyMe16-Oct-05 4:02
CandyMe16-Oct-05 4:02 
Help please.

My windows form contains tab Control which is used to navigate through a number of user controls (tabpages). My windows form contains back, next and cancel buttons.

When I click Next button, I want to be able to validate the contents of the usercontrol inside the currently selected tab page. 1. But if I put my validation inside the windows form Next event, I need to instantiate my usercontrol and thus, contents are emtpy. (I'm not sure if this is the correct approach assuming I place my validations inside Next event of Win form.)

2. If I put my validation inside the usercontrol,
but I cannot put it in Validating or Validated event, because if I don't set focus on the particular control, (e.g, textbox2), and only set focus to textbox1, and click Next button, it doesn't perform its textbox2 validation.

So I placed it inside Leave event of usercontrol. Unfortunately, if there's an error in validation, it applies to all buttons (back next and cancel) of my windows form.

For instance,

//UserControl class
<br />
... Leave event ...<br />
if (tbName.text == string.emtpy)<br />
     errorProvider1.setError(tbName, "Cannot be emtpy.");  <br />
else<br />
     errorProvider1.setError(tbName, "");<br />
<br />
if (errorProvider.getError(tbName) != "")<br />
     MessageBox.Show("Please validate data.");


So when I click Cancel which is suppose to close my window, it displays messagebox. =(

Where should I put my validation? inside windows form (particularly Next event) or inside user control (leave event? or other events)? before it even leaves.

if I put my validation in Windows form,
I use this approach:
I access the tabpage which contains imagekey that is set to the specific user control.
so if the imagekey matches the user control, then i
set error messages, etc but the contents of the control is always empty (textName).

... Next event ...
 Control.ControlCollection c = this.tabWizard.Controls;<br />
            System.Windows.Forms.TabPage tabPage = new TabPage();<br />
<br />
            foreach (Control ctl in c)<br />
            {<br />
                tabPage = (System.Windows.Forms.TabPage)(ctl);<br />
                if (tabPage.ImageKey.ToString() == "Profile")<br />
                {<br />
                    WizCreateProfile cp = new WizCreateProfile();<br />
                    if (cp.tbName.Text == string.Empty)<br />
                    {<br />
                        cp.errProvider.SetError(cp.tbName, "Please provide a profile name.");<br />
                        validateName = false;<br />
                    }<br />
                    else<br />
                        cp.errProvider.SetError(cp.tbName, "");<br />
                }<br />
            }<br />
<br />
            if (validateName == false)<br />
                MessageBox.Show("Error");

... end ...

Please help. Thank you so much.
QuestionC# boardgame Pin
mrgruby16-Oct-05 1:16
mrgruby16-Oct-05 1:16 
AnswerRe: C# boardgame Pin
Rob Philpott16-Oct-05 2:36
Rob Philpott16-Oct-05 2:36 
GeneralRe: C# boardgame Pin
mrgruby16-Oct-05 6:25
mrgruby16-Oct-05 6:25 
AnswerRe: C# boardgame Pin
pseudonym6716-Oct-05 4:49
pseudonym6716-Oct-05 4:49 
GeneralRe: C# boardgame Pin
mrgruby16-Oct-05 6:35
mrgruby16-Oct-05 6:35 
QuestionA shell extension for a virtual drive Pin
iulian.bobalca16-Oct-05 1:11
iulian.bobalca16-Oct-05 1:11 
AnswerRe: A shell extension for a virtual drive Pin
Dave Kreskowiak16-Oct-05 2:11
mveDave Kreskowiak16-Oct-05 2:11 
GeneralRe: A shell extension for a virtual drive Pin
iulian.bobalca16-Oct-05 3:06
iulian.bobalca16-Oct-05 3:06 
AnswerRe: A shell extension for a virtual drive Pin
leppie16-Oct-05 3:34
leppie16-Oct-05 3:34 
GeneralRe: A shell extension for a virtual drive Pin
iulian.bobalca16-Oct-05 3:56
iulian.bobalca16-Oct-05 3:56 
GeneralRe: A shell extension for a virtual drive Pin
Dave Kreskowiak16-Oct-05 9:14
mveDave Kreskowiak16-Oct-05 9:14 
GeneralRe: A shell extension for a virtual drive Pin
iulian.bobalca16-Oct-05 12:07
iulian.bobalca16-Oct-05 12:07 
GeneralRe: A shell extension for a virtual drive Pin
Dave Kreskowiak16-Oct-05 15:07
mveDave Kreskowiak16-Oct-05 15:07 
AnswerRe: A shell extension for a virtual drive Pin
Heath Stewart16-Oct-05 17:35
protectorHeath Stewart16-Oct-05 17:35 
GeneralRe: A shell extension for a virtual drive Pin
leppie16-Oct-05 20:18
leppie16-Oct-05 20:18 
GeneralRe: A shell extension for a virtual drive Pin
Dave Kreskowiak17-Oct-05 1:21
mveDave Kreskowiak17-Oct-05 1:21 
AnswerRe: A shell extension for a virtual drive Pin
Heath Stewart16-Oct-05 17:38
protectorHeath Stewart16-Oct-05 17:38 

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.