Archives

 
A Telerik RadGridView can look fantastic once the columns size themselves intelligently, but getting there isn’t always obvious. This column introduces the small but essential bits of .NET code that make a grid feel polished—columns that expand to fit their content, adjust after data binding, and behave consistently no matter how the form loads. It’s a simple enhancement that instantly makes your UI feel more professional, and the code behind it is cleaner than you might expect.

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

 

 

This Article contains the following functions. These functions are used inside of another procedure to output Telerik grid column definitions

ddf_TelerikDecimalColumn

ddf_TelerikDateColumn

ddf_TelerikTextBoxColumn

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