stevegray
4Penny.net
Points: 60859

3/5/2026 10:56:41 AM

Form with a grid and Export button

* This article, and all our great SQL (General) documentation, Is available on the SQL (General) menu

This SQL code will produce a code for a .NET form that has a Telerik RadGridView and an export button. 

You'll need to run all these functions first. 

 

I realized that not many people are going to want to create a form exactly the way that I create a form. It's pretty specific. But what you can get out of this is how to code T SQL code that creates code for a .NET form

 

Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Imports Telerik.WinControls.UI.Export
Imports Telerik.WinControls.Export
Public Class COA
    Private Sub COA_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        Dispose()
        GC.Collect()
    End Sub
  
    Private Sub COA_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try
  
            SetupGrid()
            BindGrid()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
  
    Private Sub SetupGrid()
        Try
            Dim oTelerikGrid As New FPTelerikCommon.TelerikGrid
            RadGridView1.Columns.Add(oTelerikGrid.createGridViewDecimalColumn("RowID", "RowID", "{0:f0}",80, False, False))
            RadGridView1.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("GL Account", "GL_Account", 100, 100, False, True))
            RadGridView1.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("GL Account Description", "GL_Account_Description", 255, 255, False, True))
            RadGridView1.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("Reporting Group L2", "Reporting_Group_L2", 255, 255, False, True))
 
  
  
            'set grid level properties
            RadGridView1.EnableGrouping = False
            Me.RadGridView1.MasterTemplate.AutoExpandGroups = True
            RadGridView1.AllowAddNewRow = True
            RadGridView1.AllowDeleteRow = True
            RadGridView1.AllowEditRow = True
            RadGridView1.EnableFiltering = True
            RadGridView1.MasterTemplate.EnableSorting = True
  
  
        Catch ex As Exception
            MsgBox(ex.Message
        End Try
    End Sub
  
    Private Sub BindGrid()
        Try
            RadGridView1.DataSource = DAL.SPs.dd_COA_SEL("datawh").getTable
            RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None
            For Each col As GridViewColumn In RadGridView1.Columns
                col.BestFit()
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
  
    Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
        Try
            FPTelerikCommon.TelerikGrid.ExportToXLSX(RadGridView1)
            MsgBox("Complete")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
  
    End Sub
End Class

 

 

4Penny.net
Version: Unknown or N/A
Section: SQL Scripts
Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
3