Foreach cannot operate on a 'method group'. Did you intend to invoke the 'method group'?
-
From the code below, I am getting three different errors. The first has to do with the Listbox UpdateBegin/Endupdate. The next error has to do with the 'Foreach' statement and 'in'. private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //The result of the open file dialog is either true or false. Nullableresult = dlg.ShowDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = true; dlg.Filter = "Media files (*.mp3 | *.wav | *.wma | *.avi | *.mp4 | *.mpg | *.wmv)"; //If the result of the open file dialog was true then.... if (result == true) { //Stop the list box from drawing while items are added. lstBxList.UpdateBegin(); <<
-
From the code below, I am getting three different errors. The first has to do with the Listbox UpdateBegin/Endupdate. The next error has to do with the 'Foreach' statement and 'in'. private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //The result of the open file dialog is either true or false. Nullableresult = dlg.ShowDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = true; dlg.Filter = "Media files (*.mp3 | *.wav | *.wma | *.avi | *.mp4 | *.mpg | *.wmv)"; //If the result of the open file dialog was true then.... if (result == true) { //Stop the list box from drawing while items are added. lstBxList.UpdateBegin(); <<
Tichaona J wrote:
Any ideas...???
yes. read the documentation for each of the class members you intend to use. and pay attention to Intellisense when it is available. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
From the code below, I am getting three different errors. The first has to do with the Listbox UpdateBegin/Endupdate. The next error has to do with the 'Foreach' statement and 'in'. private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //The result of the open file dialog is either true or false. Nullableresult = dlg.ShowDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = true; dlg.Filter = "Media files (*.mp3 | *.wav | *.wma | *.avi | *.mp4 | *.mpg | *.wmv)"; //If the result of the open file dialog was true then.... if (result == true) { //Stop the list box from drawing while items are added. lstBxList.UpdateBegin(); <<
dlg.OpenFiles
is a method groupdlg.OpenFiles()
is a method that returns a bunch of stringsProud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
From the code below, I am getting three different errors. The first has to do with the Listbox UpdateBegin/Endupdate. The next error has to do with the 'Foreach' statement and 'in'. private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //The result of the open file dialog is either true or false. Nullableresult = dlg.ShowDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = true; dlg.Filter = "Media files (*.mp3 | *.wav | *.wma | *.avi | *.mp4 | *.mpg | *.wmv)"; //If the result of the open file dialog was true then.... if (result == true) { //Stop the list box from drawing while items are added. lstBxList.UpdateBegin(); <<
Perhaps you could wrap your code in a PRE block and paste the exact error messages you are getting and indicate which line they are occurring on? Here's an example of how to use a PRE block:
<pre lang="C#">List<int> x = new List<int> {1, 2, 3};</pre>
Here's what that looks like:
List<int> x = new List<int> {1, 2, 3};
You can edit your original message to make that change.
-
dlg.OpenFiles
is a method groupdlg.OpenFiles()
is a method that returns a bunch of stringsProud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Ian Shlasko wrote:
a bunch of strings
streams actually, which makes it sound like a rather expensive method. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Ian Shlasko wrote:
a bunch of strings
streams actually, which makes it sound like a rather expensive method. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
Ah, I was just deriving from context... So he's got more bugs buried underneath the bugs he's spotted :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Ah, I was just deriving from context... So he's got more bugs buried underneath the bugs he's spotted :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)don't worry, the compiler will spot them. And we will be informed, no doubt. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Perhaps you could wrap your code in a PRE block and paste the exact error messages you are getting and indicate which line they are occurring on? Here's an example of how to use a PRE block:
<pre lang="C#">List<int> x = new List<int> {1, 2, 3};</pre>
Here's what that looks like:
List<int> x = new List<int> {1, 2, 3};
You can edit your original message to make that change.
Thanks everyone...
-
From the code below, I am getting three different errors. The first has to do with the Listbox UpdateBegin/Endupdate. The next error has to do with the 'Foreach' statement and 'in'. private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //The result of the open file dialog is either true or false. Nullableresult = dlg.ShowDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = true; dlg.Filter = "Media files (*.mp3 | *.wav | *.wma | *.avi | *.mp4 | *.mpg | *.wmv)"; //If the result of the open file dialog was true then.... if (result == true) { //Stop the list box from drawing while items are added. lstBxList.UpdateBegin(); <<
I finally figured it out, this works as intended: //Open files into the list box private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = IsEnabled; dlg.Filter = "Media files(*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv)|*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv|All files(*.*)|*.*"; //The result of the open file dialog is either true or false (didn't work). Nullable<bool> result = dlg.ShowDialog(); //If the result of the open file dialog was true then.... if (result == true) { string[] files; files = dlg.FileNames; foreach (string file in files) { lstBxList.Items.Add(file); } } }
-
I finally figured it out, this works as intended: //Open files into the list box private void btnLoad_Click(object sender, RoutedEventArgs e) { //Declare an instance of the open file dialog... OpenFileDialog dlg = new OpenFileDialog(); //Set properties for the dialog... dlg.Title = "Select one or more media files"; dlg.Multiselect = IsEnabled; dlg.Filter = "Media files(*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv)|*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv|All files(*.*)|*.*"; //The result of the open file dialog is either true or false (didn't work). Nullable<bool> result = dlg.ShowDialog(); //If the result of the open file dialog was true then.... if (result == true) { string[] files; files = dlg.FileNames; foreach (string file in files) { lstBxList.Items.Add(file); } } }
yes, that looks better, except that you are still not using PRE tags to show a code snippet. :((
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.