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.
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.
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, […]
How to launch an URL in the default browser
If you pass a URL to the Windows Shell, it will open it with the appropriate application, in this case the default browser. Thus, to launch the Geekpedia website in the default browser, the following code is needed: System.Diagnostics.Process.Start(“http://www.geekpedia.com”);
How can I set the date of a Calendar control to the current date?
Most of the time when using a calendar in your Windows or web application, you’ll want to set its initial date to the current date. This can be easily done using the SelectedDate property: Calendar1.SelectedDate = System.DateTime.Now;
How can I compress files from my C# application?
If you want to reduce the size of a file from your .NET application you will probably want to use a library that compresses this file using GZip/Zip or other similar type of compression.There are numerous libraries for this, such as: SharpZipLibPowerTCP Zip CompressionXCeed Streaming Compression for .NET