Suppose you have a ListBox named listBox1. If you want to remove the selected item from it, use the Items.Remove() method, and pass as an argument the SelectedItem property: listBox1.Items.Remove(listBox1.SelectedItem); However if the ListBox has the SelectionMode set to MultiExtended and you want to remove all the selected items, use the following code: while(lstKeys.SelectedItems.Count > 0){lstKeys.Items.Remove(lstKeys.SelectedItem);}
What are the special directories in ASP.NET 2.0
When creating a new ASP.NET 2.0 website in Visual Studio 2005 you may notice the App_Data and/or the App_Browsers directories. App_Data is a directory reserved for databases and database related files, such as .mdb (Microsoft Access Database), .mdf (Microsoft SQL Express) or XML files. The main advantage of using this folder over any other folder is the preconfigured access permissions, […]
What is the difference between the int and Int32 datatype, or String and string (lowercase)?
Int32 is the System.Int32 class, while int is an alias for System.Int32.The same applies for String (uppercase S) which is System.String, while string (lowercase S) is an alias for System.String.So basically int is the same thing as Int32, and string is the same thing as Int32. It’s down to user’s preference which one to use but most prefer to use int and string as they are easier to type and more familiar among C++ programmers.
How can I pass command line arguments while debugging within Visual Studio .NET?
When running your application you might want to call certain command line arguments. You can do this easily from within Visual Studio .NET 2003.From the Project menu choose Properties. Navigate to Configuration Properties and to Debugging. Now you can see the Command Line Arguments field in the right pane, as in the image below:
Where can I report a bug that I found in a Microsoft product such as Visual Studio?
MSDN has a wonderful bug and suggestion submission system at MSDN Product Feedback Center. After you submit bugs and suggestions you can track them. You can also see other people’s feedback.
In .NET 2.0 sending email with System.Web.SmtpMail doesn’t seem to work anymore
In .NET 2.0 System.Web.SmtpMail has been changed to System.Net.Mail.SmtpClient.More information at MSDN – System.Net.Mail Namespace.
In .NET 2.0 accessing the values stored in web.config through System.Configuration.ConfigurationSettings.AppSettings doesn’t seem to work anymore
In .NET 2.0 System.Configuration.ConfigurationSettings.AppSettings has been changed to System.Configuration.ConfigurationManager.AppSettings. Also youneed to add a reference to System.Configuration.dll.Here’s an example of accessing the SomeString value from the web.config file, in .NET 2.0: System.Configuration.ConfigurationManager.AppSettings[“SomeString”];
Can ASP.NET 1.1 applications work along with ASP.NET 2.0 applications?
As long as you have ASP.NET 1.1 and ASP.NET 2.0 installed on your server, both types of web applications will work fine. When you install ASP.NET 2.0, ASP.NET 1.1 doesn’t get uninstalled so you don’t have to worry.However, after you install ASP.NET 2.0 make sure you put your ASP.NET 2.0 web applications on a different […]
How do I generate a random number within a range?
Using .NET you can easily generate a random number withing a range, by using the Random class. In the following example a random number between 1 and 69 will be generated: System.Random RandNum = new System.Random();int MyRandomNumber = RandNum.Next(69); To generate a random number between 1986 and 2005 you would use: System.Random RandNum = new System.Random();int MyRandomNumber = RandNum.Next(1986, […]
How do I change the mouse cursor to a hourglass?
With .NET you can easily change the current cursor by using the Cursors class. To change the cursor to a hourglass, we’ll be using the WaitCursor: this.Cursor = Cursors.WaitCursor; To change it back to normal after the application has stopped loading: this.Cursor = Cursors.Default; As IntelliSense points out, you can change the mouse cursor to various shapes (crosshair, […]