DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Ray Wood Guest

    changing datagrid properties at run time


    I have populated a ADO Datagrid using T-SQL and a DataControl at design time.
    Under some circumstances I would like to expose more of the columns in the
    original query.
    Can I change a columns visibility or any other single property at run time
    without losing my other settings like column titles entered at design time?
    I have found almost nothing on the ADO Datagrid, Do you know of any good
    resources? Should I be using DBGrid?

    Thanks,
    Ray


  2. #2
    Marko Sink mailcity.com Guest

    Re: changing datagrid properties at run time


    In VB menu Project -> references include :
    "Microsoft Data Formatting Object Library".

    Sample :

    Private sub procFormatDataGrid1

    Dim formatX As StdDataFormat, formatY As StdDataFormat
    Set formatX = New StdDataFormat
    Set formatY = New StdDataFormat
    DataGrid1.Columns(0).Visible = False
    DataGrid1.Columns(1).Caption = "Code"
    DataGrid1.Columns(1).Width = 1200
    DataGrid1.Columns(2).Visible = False
    DataGrid1.Columns(3).Caption = "Name"
    DataGrid1.Columns(3).Width = 4200
    DataGrid1.Columns(4).Caption = "Price"
    DataGrid1.Columns(4).Width = 1300
    DataGrid1.Columns(5).Caption = "Tax"
    DataGrid1.Columns(5).Width = 1300
    DataGrid1.Columns(6).Caption = "Comment"
    DataGrid1.Columns(6).Width = 5000

    formatX.Type = fmtCustom
    formatX.Format = "#.##0,00"
    formatY.Type = fmtCustom
    formatY.Format = "#.##0,00%"


    Set DataGrid1.Columns("Price").DataFormat = formatX
    DataGrid1.Columns("Price").Alignment = dbgRight

    Set DataGrid1.Columns("Tax").DataFormat = formatY
    DataGrid1.Columns("Tax").Alignment = dbgRight

    DataGrid1.Columns(6).WrapText = True

    End Sub


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links