C# - Controls
Load Directories And Files In TreeView Control
Date : 25 Dec 2009
Views : 2116
This code snippet shows how to load directories and sub directories and files into a tree control.
ComboBox DataSource From XML
Date : 19 Nov 2009
Views : 2501
This code snippet shows how to add items to a ComboBox control using a DataSet object, which reads an XML file.
ListView With Headers And Items
Date : 19 Nov 2009
Views : 774
This snippet shows how to add header and items to a ListView control using string arrays.
ListView Click Event
Date : 19 Nov 2009
Views : 1941
This snippet shows how to add items to a ListView control and add a click event to view the selected item in a message box.
Object List Binding Example
Date : 18 Nov 2009
Views : 836
This snippet shows how to bind an object to a ListBox control DataSource and DisplayMember.
Add Icons To ImageList Example 1
Date : 09 Sep 2009
Views : 2502
This snippet adds icons to an ImageList from the applications startup path. You can store all your icons in a folder and use this snippet to load all icons into the ImageList using a loop.
Get Position Of All TextBoxs
Date : 09 Sep 2009
Views : 689
This code snippet gets the position, name and text of all TextBox controls on a form using a foreach loop.
Get Text From TextBox Array
Date : 09 Sep 2009
Views : 2448
This code snippet creates 5 TextBox controls and places them on the form. You can get the text as your typing using the TextChange() event for any of the focused textbox's.
Get Selected List In DataGridView
Date : 09 Sep 2009
Views : 1022
This snippet returns a list of all DataRows selected in DataGridView.
Add Items To CheckedListBox From File
Date : 05 Sep 2009
Views : 1046
This snippet adds items to a checkedListBox from a text file. Create a text file and save the items on separate lines. Do not leave a blank line at the end of the text file. New Snippets
Update Content Label Text From Master Page
ASP.Net - C#
Miscellaneous
The following code snippet demonstrates how to update the Text property of a Label control located in a page which uses a master page from within the master page code behind file.
HTML Table Paging
Javascript
Navigation
The following code snippet demonstrates how to apply paging to a HTML table element.
Get Textarea Data Length
Javascript
Miscellaneous
The following code snippet demonstrates how to display the data length of a textarea element as the user types in data.
Custom TextBox Control With BackColor Hover
C#
Controls
The following code snippet demonstrates how to create a custom TextBox control, which can change its background color when a user hovers over the TextBox control.
TextBox Validating Event
C#
Controls
The following code snippet demonstrates how to validate TextBox controls using the Validating event.
Bing Map Control
C# - Windows Mobile
Controls
This simple code snippet demonstrates how to set the latitude and longitude for the Bing Map control.
Count Down Timer
C# - Windows Mobile
Miscellaneous
This code snippet demonstrates how to use the DispatcherTimer class to create a count down timer.
Edit And Update A listView Control
ASP.Net - C#
Controls
The following code snippet demonstrates how to bind a ListView control to a DataTable object and allow the user to edit rows using the ItemEditing and ItemUpdating events of the listView control. This example uses a Microsoft SQL Server and connects to the sample AdventureWorks database.
Remove All Options From Select
Javascript
Miscellaneous
The following code snippet demonstrates how to clear a select element and remove all options from it.
ListView With DataPager
ASP.Net - C#
Controls
The following code snippet demonstrates how to page through a ListView control using the DataPager control.
Bind ListView To DataTable
ASP.Net - C#
Controls
The following code snippet demonstrates how to bind a ListView control to a DataTable object. It also shows how to use the ItemTemplate to display the data.
XmlWriterSettings Example
ASP.Net - C#
XML
The following code snippet shows how to indent Xml data when using the XmlWriter class.
Deserialize Object From Xml File
ASP.Net - VB
XML
The following code snippet demonstrates how to deserialize an object from an Xml file and cast the object back into its original type.
Serialize Object To Xml
ASP.Net - VB
XML
The following code snippet demonstrates how to serialize an object and save it to an Xml file using the XmlSerializer class.
Save And Load Images Drawn On Canvas
C# - Windows Mobile
Graphics
The following code snippet demonstrates how to draw on a canvas. The canvas image can then be saved and loaded. Images are saved to isolated storage. |
Top C# SnippetsThis snippet shows how to develop a custom panel which is semi transparent by overriding CreateParams and the OnPaint method of the Panel control. This sinppet opens an image for reading as bytes. The bytes are then placed into a memorystream which is used to create a bitmap image of the bytes. The image is then set as the forms background image. This snippet checks if the current thread is alive. TThis code snippet gets the filename and path of a selected file using the FileOpenDialog Class. This snippet adds items to a listview control. It loops through the files in the C:\ drive and displays the filename in the listview control. This code snippet gets the filename of a selected file from the Open File Dialog and displays it in a message box. This snippet uses the TripleDESCryptoServiceProvider Class to encrypt a string and save it to a text file. The key to decrypt the file is also saved into a seperate text file. This snippet checks to see if a file exists using the FileInfo Class. This code snippet displays only the checked items in a message box. A foreach loop is used to determin, which items have been checked. A good example of this snippet is to allow a user to check multiple fruits and display the checked fruits in a message box. Make sure the checkedListBox contains items. This simple snippet demonstrates how to use the IEnumerable interface to loop through a custom collection using the foreach loop. |