Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are delegates necessary?

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
GB
I have a form with 3 file paths displayed - before they are displayed there is a function that checks to see if all filepaths are valid - if not an error provider is invoked and flashes a red symbol by the offending filepath. There is a button next to each file path so you can change it to a valid path. All filepath info is stored in XML file too.

I want other controls to be activated if all filepaths are correct - would I use delegate methodology to run many methods at the same time to check filepaths, enable buttons, remove flashing error symbols etc? It doesnt seem right to keep specifiying in my click events etc, to run my ParseFileLoactions() method. See below:

Code:
private void ParseFileLocations()
		{
			XmlNodeList xmlNodeList = _doc.SelectNodes("//filesettings");
			foreach (XmlNode item in xmlNodeList)
			{
				XmlElement element = (XmlElement) item;
				string type = element.GetAttribute("type");
				string path = element.GetAttribute("path");
				
				switch (type)
				{
					case "baseLayer":
						txtBaseLayer.Text = path;

						if (CommonLib.DoesFileExist(path) == false)
							errorProvider1.SetError(txtBaseLayer, "File not found");
						else
							errorProvider1.SetError(txtBaseLayer, "");
							_dataGeneration.BaseLayerLocation = path;
						break;

					case "habitatGroupsDbf":
						txtHabitatGroupsDbf.Text = path;

						if (CommonLib.DoesFileExist(path) == false)
							errorProvider1.SetError(txtHabitatGroupsDbf, "File not found");
						else
							errorProvider1.SetError(txtHabitatGroupsDbf, "");
							_dataGeneration.DbfLocation = path;
						break;

					case "outputShapefiles":
						txtShpOutputDir.Text = path;

						if (CommonLib.DoesDirExist(path) == false)
							errorProvider1.SetError(txtShpOutputDir, "Directory not found");
						else
							errorProvider1.SetError(txtShpOutputDir, "");
							_dataGeneration.OutputLocation = path;
						break;
				}
			}
		}
 
This sounds like a true GUI design issue.

From the sounds of it, you don't want the user to move onto the next step until the first set of textboxes contain valid data.

Does this not sound like a wizard to you?

Step 1:
Enter 3 Valid File Paths (enable next button when 3 are completed and do your verification on the click)

Step 2:
Begin the next step with your new controls.


I don't think I would use delegates in the case you are talking about. I would use the TextChanged event on your 3 text boxes to enable the next button but that's it.

Hope that gives you some ideas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top