Source Code - http://www.paulbradley.org/46/
Get free Visual basic 2010 source codes. Learn Visual Basic 2010 using this website.
Showing posts with label DataGrid. Show all posts
Showing posts with label DataGrid. Show all posts
Sunday, September 18, 2011
Wednesday, September 14, 2011
Add a table and column to a DataGrid programmatically
Bind a DataGrid control to a DataSet. After, declare a new TableStyle and set its name.
Declare a new column style and after set its name and other properties.
Call the Add method of the GridColumnStylesCollection object to add the column to the table style
Dim ts1 As New DataGridTableStyle() ts1.MappingName = "Laptops"
Declare a new column style and after set its name and other properties.
Dim myDataCol As New DataGridBoolColumn() myDataCol.HeaderText = "New Column" myDataCol.MappingName = "Laptop"
Call the Add method of the GridColumnStylesCollection object to add the column to the table style
ts1.GridColumnStyles.Add(myDataCol)Call the Add method of the GridTableStylesCollection object to add the table style to the data grid.
DataGrid1.TableStyles.Add(ts1)
Friday, September 9, 2011
Type Ahead Text-Filter PFGrid.NET Winforms
Thursday, September 8, 2011
DevExpress Webinars - Introduction to Data Access and customization with the Silverlight Grid
In this webinar, we'll take a look at the different ways to access, display and work with data using the Data Grid control for Silverlight. We'll further look at the customization as well as the printing and export options available to the grid.
Wednesday, August 31, 2011
Friday, June 17, 2011
Export DataGrid to Microsoft Excel
If you want to export DataGrid to Microsoft Excel write the code bellow:
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Data
Imports System.Windows.Forms
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim j As Integer
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To DataGridView1.RowCount - 2
For j = 0 To DataGridView1.ColumnCount - 1
xlWorkSheet.Cells(i + 1, j + 1) = _
DataGridView1(j, i).Value.ToString()
Next
Next
xlWorkSheet.SaveAs("C:\test.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("You can find the file C:\test.xlsx")
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Data
Imports System.Windows.Forms
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim j As Integer
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To DataGridView1.RowCount - 2
For j = 0 To DataGridView1.ColumnCount - 1
xlWorkSheet.Cells(i + 1, j + 1) = _
DataGridView1(j, i).Value.ToString()
Next
Next
xlWorkSheet.SaveAs("C:\test.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("You can find the file C:\test.xlsx")
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class
Subscribe to:
Posts (Atom)