November 2007 Entries
A common question I see in the msdn forums is How do I databind a Listview control on a windows form. Unfortunately the windows forms ListView does not support databinding. The wpf version does support databinding and it pretty host on a windows form. Please note you need to have the .Net Framework 3.0 or greater installed for this.
In VS 2008 you will have a WPF Interoperability tab in the toolbox. Drag a ElementHost on to your windows forms. In VS 2005 you will have to add the ElementHost to the toolbox.
For this example I am going to...
Linq allows you to query the data in a dataset. For this example I load the Products and Categories table from the Northwind Database. I then do a join query to export the Product Name, Unit Price, and Category Name into a list which I display in a datagridview. Note a query of this type will not display in a datagridview you need to set the datasource equal to the query's Tolist method.
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConn As String = _
"Server = .\SQLEXPRESS;Database...
The Space Coast .Net User Group will be having VS 2008 install fest on Dec 18, 2007 @ 6:30PM
Bring your laptop to the meeting room at Charlie and Jakes and the great Joe Healy will allow you to install a copy of Visual Studio 2008 professional for free. While Visual Studio 2008 is installing buy yourself something to eat or drink and have some fun.
** Visual Studio 2008 must be installed at the meeting **
** Pease uninstall any Orcas or VS 2008 betas before the meeting **
There are a limited number of copies of VS 2008 available...
Visual Studio 2008 allows you to switch which version of the .net framework your project targets. The available options are 2.0, 3.0, and 3.5.
To change the framework version open up your project properties compile tab
You will find the framework option combobox on the form that opens when you press the Advanced Compile Options button
Visual studio will save the project, close, and finally restart with project opened up when you change the framwork version for your project
For this example we are going to create a Excel 2007 spreadsheet using the Microsoft OpenXml Sdk and Linq to XML.
To start with lets create a new Windows forms app which targets the .Net Framework 3.5. Add a Linq to Sql design surface to your project and name it Northwind and drag the Northwind Products table on to the surface. On the windows form I added a DataGridview to display the data we are going to export to excel. We also need a button named btnExport on the form.
To create a excel spreadsheet we need to use the...