Subscribe: TheScarms VB.NET and C# Code Library
http://www.thescarms.com/dotnet/dotnet.xml
Preview: TheScarms VB.NET and C# Code Library

TheScarms VB.NET and C# Code Library



Loaded with VB.NET and C# solutions to all your .NET questions!



 



Programmatically add new columns to a .NET DataTable.
How to Programmatically add new columns to a .NET DataTable



Get the path to your VB or C# .NET application.
Get the path to your VB or C# .NET application.



Get your .NET Application's Assembly path and Information.
Get your .NET application's assembly information.



Retrieve your .NET Application's configuration data (appSettings) using C# or VB.
Retrieve your .NET Application's configuration data (appSettings) using C# or VB.



Save an ADO.NET DataSet to Excel in ASP.NET.
How do I save a DataSet to Excel in ASP.NET.



Change the cursor to a Wait cursor in ASP.NET
Change the cursor to a Wait cursor in ASP.NET.



.NET Assemblies, Global Assembly Cache, Versioning, Manifests and Deployment
Learn about .NET Private and Shared Assemblies, Modules, Global Assembly Cache (GAC), GacUtil.exe, Side by Side Versioning, Manifests and Deployment.



Bind an ADO.NET DataSet or DataTable to a Combobox in VB.NET
Bind an ADO.NET DataSet or DataTable to a Combobox in VB.NET using the ComboBox's DisplayMember and ValueMember properties to display one value but use a different value.



Adding, removing and enumerating items in .NET collections, hashtables and arraylists
How to add items to, remove items from and enumerate through .NET collections, hashtables and arraylists which all derive from the System.Collections namespace.



Prevent column resizing in the .NET WinForms DataGrid via subclassing
Prevent users from resizing columns in the .NET WinForms DataGrid by deriving a new DataGrid and overridding its OnMouseDown method.



Format columns in the .NET Winforms Datagrid
Format columns in the .NET Winforms Datagrid using a DataGridTableStyle and GridColumnStyles for each DataColumn bound to your DataTable



Add DataRows to a Combobox in VB.NET without using data binding.
Add DataRows to a Combobox in VB.NET without using data binding to overcome a bug in V1.1 of the .NET Framework.



Display a Confirmation dialog when the DEL key is hit in a .NET WinForms DataGrid
Display a Delete Confirmation dialog when the DEL key is pressed in a .NET WinForms DataGrid by subclassing the DataGrid and overriding its ProcessDialogKey method.



Issue modal JavaScript dialogs from an ASP.NET web page
Issue a modal JavaScript dialog to the user from an ASP.NET web page using the web page's RegisterStartupScript method and the session object



Read and write cookies in ASP.NET web pages
Read and write cookies and set cookie properties in ASP.NET web pages using the Request.Cookies and Response.Cookies CookieCollections.



Programmatically pass parameters into a Crystal report from VB.NET.
Programmatically pass parameter values into a Crystal report at run time from VB.NET using the Crystal ReportDocument and ParameterValues objects.



Dynamically run Crystal Reports in VB.NET using the Crystal Report Viewer control.
Programmatically load and run a Crystal report from VB.NET and view it using the Crystal Report Viewer control.



Change the color of individual ListBox items in .NET by overriding the DrawItem event.
Change the color of individual ListBox items with C# and .NET by writing your own handler for the ListBox's DrawItem event



Conditionally set ASP.NET control properties on .ASPX pages with the Databinder object
Conditionally set properties of ASP.NET control on .ASPX web pages at run time using Template Columns and the Databinder class of the System.Web.UI namespace.



Add databound comboboxes to the .NET WinForms DataGrid using derived datagrid column styles
Add a databound ComboBox to the .NET WinForms DataGrid using VB.NET or C# by deriving a new datagrid column style from the DataGridTextBoxColumn class



See if your ADO.NET's DataSet's contents have changed via the RowState property
Determine if your ADO.NET's DataSet's contents have changed by examining the RowState for each DataRow returned by the DataTable's GetChanges method.



Get a DataSet's current row after the bound DataGrid was sorted
Get a DataSet's current row after its bound DataGrid was sorted using the Current property of the DataGrid's BindingContext or via the CurrencyManager



Debug .NET code with the Trace class and EventLog and TextWriter listeners
Debug .NET code at runtime with Trace output and the EventLogListener and the TextWriterListener provided by the System.Diagnostics namespace.



TheScarms .NET Code Library
heScarms Visual Basic.NET, C#, ADO.NET, and ASP.NET Code Library



Set default values for new DataRows added to an ADO.NET DataTable
VB.NET snippet showing how to set default values for new DataRows being added to an ADO.NET DataTable



Derive or subclass a WinForms Datagrid or other control in .NET
Derive or subclass an existing Winforms Datagrid or any other control in .NET to create a new custom control



Disable the TAB, Arrow, Home, End, Page keys in the .NET Winforms DataGrid
Disable the TAB, Arrow, Home, End, Page Up and Page Down keys in the .NET WinForms DataGrid by deriving a new DataGrid and overriding its ProcessCmdKey mewthod



Make an ADO.NET DataGrid row read only based on a cell's value.
Make a DataGrid row read only when it is clicked based on a cell's value. Also, see how to work with delegates, events, and event arguments.



Prevent deletes when the DEL key is hit in a .NET Winforms DataGrid
Prevent Deletes when the DELete key is pressed in a WinForms DataGrid by subclassing the DatasGrid and overriding its ProcessDialogKey and PreProcessMessage methods.



Create a Crystal Report using a .NET DLL as the report's datasource.
Create a Crystal Report using a .NET DLL as the report's datasource. The DLL exposes methods which return DataTables that are consumed by the report.



TheScarms ADO.NET Code Library
TheScarms.com ADO.NET DataSet/DataTable Related Code Samples



TheScarms ASP.NET Code Library
TheScarms.com ASP.NET and Web Application Samples



TheScarms .NET Crystal Report Related Samples
How to use Crystal Reports with .NET applications



Debugging and Error Handling Related Articles in .NET
How to debug code and handle errors in .NET applications



TheScarms .NET samples to send e-mail
Learn how to send E-mail with attachments from VB.NET applications



TheScarms .NET Environmental Related Samples
Learn about the GAC, Assemblies, Retrieving Environmental Related Information



TheScarms .NET General Programming Samples
Sample programs and solutions covering everyday programming issues



TheScarms WinForms DataGrid Related Library
Working with the .NET WinForms DataGrid Control



TheScarms .NET Code Library - Working with files
.NET I/O related examples on how to work with the file system



Using Microsoft Excel from .NET
Work with Microsoft EXCEL from .NET via the Excel Interop



.NET Security Related Issues
.NET Security Related Examples



TheScarms String Processing in .NET
Working with String and Regular Expressions



TheScarms .NET WinForm and Control Related Code Samples
Examples of working with and extending WinForms and Winform Controls



Check for duplicate DataGrid rows before saving the DataGrid's data.
Locate duplicate DataGrid rows before saving the DataGrid's data by looping through the data and filtering the underlying datatable.



Dynamically read in, compile, and execute VB.NET source code.
Dynamically read in, compile, and execute VB.NET source code by programmatically invoking the .NET compiler, loading the compiled assembly, and executing it.



Edit a .NET 2003 solution with an earlier version of .NET.
Edit a .NET 2003 solution with an earlier version of .NET. by modifying the .SLN solution file.



Send email with attachments from a VB.NET application
Send rich format email with attachments in VB.NET using the System.Web.Mail namespace and the Smtp mail protocol.



Programmatically end the editing of a cell in the .NET Winforms DataGrid
Programmatically end the editing of a cell in the .NET Winforms DataGrid so the cell is flagged as changed when it looses focus.



Enumerate through the values of an ENUMeration structure in VB.NET
Programmatically Enumerate or loop through the values of an ENUMeration structure in VB.NET.



Add and remove event handlers dynamically in VB.NET
Associate and disassociate a block of code (handler) with an event dynamically at run time in VB.NET using the AddHandler and RemoveHandler methods.



Create, Read, Write and Delete Event Logs with VB.NET
Create, read, write and delete Windows event logs in VB.NET with the EventLog class from the Imports System.Diagnostics namespace.



Populate an Excel Worksheet from a .NET application using the Excel Object.
Populate an Excel Worksheet from a .NET application using the Excel object via COM and the Interop layer provided by the .NET Framework.



Detect when a file or folder changes with .NET's FileSystemWatcher
Detect when a file or the contents of a folder change with .NET's FileSystemWatcher. Watch for specific events and associate handlers with these events.



Format data in a bound DataGrid on an ASP.NET web page.
Format how data displays in a bound DataGrid on an ASP.NET web page using the DataFormatString command.



Add/remove a shared assembly to/from the .NET Global Assembly Cache (GAC)
Add/remove a shared assembly to/from the .NET Global Assembly Cache (GAC) using GacUtil.exe which ships with .NET



Hide columns in the .NET Winforms Datagrid
Hide columns in the .NET Winforms Datagrid using a DataGridTableStyle and a GridColumnStyle.



Get the DataGrid row or column that the user clicked on.
Get the DataGrid row or column that the user clicked using the DataGrid's HitTest method to obtain a HitTestInfo object.



Upload files from a client PC to a web server with ASP.NET
Upload files from a client PC to the web server with ASP.NET using the HtmlInputFile server control



Use the HTTP Cache to improve performance in ASP.NET web pages
Use the HTTP Cache to improve performance when loading ASP.NET web pages since the page will be retrieved from the server's memory instead of from disk.



Impersonate another user programmatically in ASP.NET
Impersonate another user programmatically in ASP.NET using the LogonUser API call so you code runs under the authority of a different user Id.



Create an Irregular shaped (non-rectangular) Windows Form using VB.NET
Create an Irregular, non-rectangular shaped form, based on any bitmap image, using VB.NET and Windows regions.



Get the current user and see if they belong to a specific security group
Get the currently logged in user and see if they belong to a specific security group using principals and the System.Threading namespace.



Determine if a string value is numeric in C# similar to VB's IsNumeric function
Determine if a string value is numeric in C# similar to VB's IsNumeric function.



Create compressed ZIP files from .NET applications
Create compressed ZIP files from .NET applications using the java.util.zip method in the MS Java Runtime



Late Bind to a COM Component in VB.NET
See how to Late Bind to a COM Components with VB.NET at runtime instead of using early binding at compile time.



Use events to limit key input to .NET WinForm DataGrid cells.
To limit key input to WinForms DataGrid cells, use a GridColumnStyle to define a DataGridTextBoxColumn for the column then associate a handler for the DataGridTextBoxColumn's KeyPress event.



List all files in a folder using VB.NET
List all files in a folder and get their attributes in VB.NET using the DirectoryInfo, GetFiles, and FileInfo constructs from the System.IO namespace.



Localize ASP.NET web pages with resource files
Localize ASP.NET web pages with resource files so the page displays its text in the language used by its viewer.



Send E-mail from a web page with the MailTo command in ASP.NET
Send E-mail, using the client PC's default e-mail application, from an ASP.NET web page with the MailTo command



Measure the height and width of a string in VB.NET.
Measure the height and width of a string in VB.NET using Graphics.MeasureString to calculate how many characters can fit in a StringFormat object which encapsulates font and line spacing information.



Change label forecolor on mouse overs in VB.NET or C#
Change a label's forecolor and font on mouse overs in VB.NET or C# by assigning it a different font object



Programmatically move columns in the .NET DataGrid.
Programmatically move columns in the .NET DataGrid through the use of a TableStyle and GridColumnStyles.



Move a .NET Form that has no title bar
Move a .NET Windows Form that has no title bar by adding code the the form's MouseDown, MouseUp, and, MouseMove events.



Working with the .NET NameValueCollection Datatype
.NET NameValueCollections are similar to Hash Tables - they store items in key/value pairs and let you retrieve items by specifying the Key or the index.



Make the .NET WinForms DataGrid have no current cell
Make the Winforms DataGrid have no current cell by deriving a new DataGrid and using the SendMessage API.



Compress NTFS files using C#
C# code to compress NTFS formatted files using the DeviceIoControl API.



Display Window's Page Setup Dialog from VB.NET using the PageSetupDialog and PrintDocument objects
Use the .NET PageSetupDialog object to display Window's Page Setup Dialog from VB.NET and work with the PrintDocument object.



Print a DataSet's contents from VB.NET using the PrintDocument object
Print a DataSet's Contents from VB.NET using the PrintDocument object accounting for text and font size, paper size, DataRow status, line wrapping, etc.



Launch and monitor external programs from .NET applications using the System.Diagnostics.Process class
Launch and monitor external programs from .NET applications using the Process class in the System.Diagnostics namespace and control external process I/O.



Add a ProgressBar to the .NET StatusBar control through subclassing
C# code to add a ProgressBar to a derived .NET StatusBar control



Read text files in .NET using the System.IO StreamReader
C# code to read text files in .NET using the System.IO namespace StreamReader object



Find unique words in a string using Regular Expressions
Use Regular Expressions and the regex object to parse a string to find all unique or duplicate words



Validate dates and other data in .NET using Regular Expressions
Validate dates and other data in .NET using Regular Expressions match predefined patterns



Read schema information from Excel worksheets with ADO.NET
Retrieve schema information from an Excel worksheet with ADO.NET using the GetOleDbSchemaTable method of the OleDBConnection connection object



Programmatically scroll the DataGrid to a particular row using the protected GridVScrolled method
Programmatically scroll the DataGrid to a particular row using the DataGrid's protected GridVScrolled method



Serialize .NET objects to store and retrieve them from a file or viewstate in ASP.NET
Serialize and de-serialize .NET object such as DataSets, classes, etc, so they can be stored in a file or stream or viewstate in ASP.NET.



Determine if ASP.NET's Session Object has timed out
Determine if ASP.NET's Session Object has timed out by examining its IsNewSession property and the ASP session Id cookie.



Set focus to a particular control on an ASP.NET web page with JavaScript
Use JavaScript from your server code to set focus to a specific control on an ASP.NET web page



Send Email from VB.NET using the equivalent of the ShellExecute API
Send Email from VB.NET using the equivalent of the ShellExecute API



Browse for folders using Shell32.dll's BrowseForFolder method in C#
Browse for folders using Shell32.dll's BrowseForFolder method in C#



Make the .NET WinForms DataGrid support single select versus multiselect mode
Make the .NET WinForms DataGrid support single select versus the default multiselect mode through subclassing and overriding its OnMouseMove and OnMouseDown methods.



Get Paths to Windows Special Folders, such as My Documents, from VB.NET
Get Paths to Windows Special Folders, such as My Documents, Desktop, Favorites, etc. from .NET by declaring a variable of type System.Environment.SpecialFolder



Get the name of the currently executing .NET method at runtime
Simplify debugging by getting the name of the currently executing .NET method at runtime using the StackFrame, StackTrace, and MethodBase classes in the System.Diagnostics and System.Reflection namespaces.



Convert Strings to Byte Arrays and Back in .NET using ASCIIEncoding
Convert Strings to Byte Arrays and Back in .NET using ASCIIEncoding and the GetBytes and GetString methods



Add multi-threading to .NET applications to improve user interface responsiveness
Add multi-threading to .NET applications to improve user interface responsiveness. Start, pause, and cancel worker threads.



Total a column in a .NET WinForms DataGrid
Sum a column in the .NET Winforms DataGrid to produce a total by looping through the DataGrid and examining its DataGridTextBoxColumn's values.



Catch and handle all unhandled exceptions in your VB.NET program with Application Domains
Catch and handle all unhandled exceptions in your VB.NET program without using Try-Catch blocks by using the Application Domain object.



Loop through ASP.NET Datagrid to retrieve cell values
Programmatically loop through ASP.NET Datagrid rows to retrieve either bound or template column values.



Create and communicate with unattended Windows Service using .NET
VB.NET sample showing how to create, install, and communicate with an unattended Windows Service using .NET



Use Windows Management Instrumentation (WMI) to get a MAC Address or Hard Drive Serial Number
Get your PC's Network Interface Card's MAC Address or Hard Drive Serial Number from VB.NET using Windows Management Instrumentation (WMI).