C# - Controls
ListView With Headers And Items
Date : 19 Nov 2009
Views : 548
This snippet shows how to add header and items to a ListView control using string arrays.
ListView Click Event
Date : 19 Nov 2009
Views : 946
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 : 520
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 : 1423
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 : 511
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 : 1304
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 : 726
This snippet returns a list of all DataRows selected in DataGridView.
Add Items To CheckedListBox From File
Date : 05 Sep 2009
Views : 699
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.
Checked Items In CheckedListBox
Date : 05 Sep 2009
Views : 1999
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.
Add items to CheckedListBox
Date : 05 Sep 2009
Views : 1081
This code snippet adds items to a CheckedListBox. Add the following code in the forms load event for an example. New Snippets
Highlight Input Element On Focus
Javascript
JQuery
This code snippet shows how to highlight an input element when it has focus and remove the highlight when it loses focus.
Calculate Age
C#
Miscellaneous
This code snippet shows how to calculate an age from a date of birth.
Sliding Tab Control
Javascript
JQuery
This code snippet shows how to develop a simple tab control, that slides tab pages when you click onto a tab.
LINQ Example 1
C#
LINQ
This code snippet uses where to find all elements of an array that is less than 10.
Simple MySQL Class To Query Database
Java
Database
The following code snippet shows how to create a simple MySql class that can be used to create a connection to the database server and execute queries which return a ResultSet object.
Connect To MySQL Database
Java
Database
This code snippet shows how to connect to a MySQL database server. You will need to download Connector/j.
File Viewer Example
Java
Controls
This code snippet shows how to open a file for reading and display the data into a JTextArea component.
JMenu With ActionListener Example
Java
Controls
This code snippet shows how to add an ActionListener to a JMenu component.
JMenuBar Example
Java
Controls
This code snippet demonstrates how to use the JMenuBar component and how to add menu items using the JMenu and JMenuItem components.
MD5 Message Digest Example 1
Java
Security
This code snippet shows how to use the MessageDigest class to get an instance of the MD5 MessageDigest. This code snippet does not return a 32 character string.
Check If File Exists
Java
File Manipulation
This code snippet checks if a file exists. If it does, it displays its absolute file path. What Others Are Viewing
Highlight Input Element On Focus
Javascript
JQuery
This code snippet shows how to highlight an input element when it has focus and remove the highlight when it loses focus.
Sliding Tab Control
Javascript
JQuery
This code snippet shows how to develop a simple tab control, that slides tab pages when you click onto a tab.
LINQ Example 1
C#
LINQ
This code snippet uses where to find all elements of an array that is less than 10. |
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. 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 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 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 code snippet gets the filename of a selected file from the Open File Dialog and displays it in a message box. This snippet checks to see if a file exists using the FileInfo Class. This code snippet will get the computers IP address. This simple snippet creates a connection to an SQLServer. This simple snippet demonstrates how to use the IEnumerable interface to loop through a custom collection using the foreach loop. |