Results 1 to 6 of 6

Thread: flexgrid use problems in vb.net

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    74

    flexgrid use problems in vb.net

    I want to use a grid like flexgrid i vb.net, where I can manually fill the grid the grid with data, set rowheight and columnwidth as I like etc.
    However - as it seems - the flexgrid i've found in vb.net - have limitations such as that columnwidth is a readonly property and so on.

    Is there some other grid I can use in vb.net that is controllable when I like to populate it and change appearance manually without connection to a database?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Well, what .NET offers is the Datagrid, Its in my opinion powerful, but it has its limitations.

    You can always still use the Flexgrid control from 6.0 if the Datagrid doesn't suite you app.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    74
    Well, I HAVE to use the flexgrid or equivalent, since I'm going to handle the grid manually - whithout connection to a database.
    But the problem is that when I use the Flexgrid - important properties such as cellwidth and rowheight seem to have become a read-only-property in VB.net.

  4. #4
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    Hi,

    I just posted about this last week, so here's some code that I learnt to help you:

    Code:
        ' Global Decs
        Public Const gcflexAlignLeftTop = 0
        Public Const gcflexAlignLeftCentre = 1
        Public Const gcflexAlignLeftBottom = 2
        Public Const gcflexAlignCenterTop = 3
        Public Const gcflexAlignCenterCentre = 4
        Public Const gcflexAlignCenterBottom = 5
        Public Const gcflexAlignRightTop = 6
        Public Const gcflexAlignRightCentre = 7
        Public Const gcflexAlignRightBottom = 8
        Public Const gcflexAlignGeneral = 9
    
        ' Local Consts
        Const cgrdDesc = 1
        Const cgrdRate = 2
        Const cgrdEnrolDate = 3
        Const cgrdRefunded = 4
        Const cgrdPrice = 5
        Const cgrdTax = 6
        Const cgrdTotal = 7
        Const cgrdSOL = 8
    
        ' Example Sub
        Private Sub RefreshForm()
            Dim strSQLStm As String
    
            ' Initialise Grid
            grdSalesLines.Rows = 1
            grdSalesLines.set_ColWidth(0, grdSalesLines.Size.Width * 0.1)
            grdSalesLines.set_ColWidth(cgrdDesc, grdSalesLines.Size.Width * 0.2)
            grdSalesLines.set_ColWidth(cgrdRate, 72)
            grdSalesLines.set_ColWidth(cgrdRefunded, grdSalesLines.Size.Width * 0.1)
            grdSalesLines.set_ColWidth(cgrdPrice, grdSalesLines.Size.Width * 0.1)
            grdSalesLines.set_ColWidth(cgrdTax, grdSalesLines.Size.Width * 0.1)
            grdSalesLines.set_ColWidth(cgrdTotal, grdSalesLines.Size.Width * 0.1)
            grdSalesLines.set_ColAlignment(cgrdEnrolDate, gcflexAlignLeftCentre)
            grdSalesLines.set_ColAlignment(cgrdPrice, gcflexAlignRightCentre)
            grdSalesLines.set_ColAlignment(cgrdTax, gcflexAlignRightCentre)
            grdSalesLines.set_ColAlignment(cgrdTotal, gcflexAlignRightCentre)
            cboEnrolDate.Visible = False
    
                strSQLStm = "SELECT tbl_SalesOrderLine.sol_SalesOrderLineNumber AS Line, tbl_ItemMaster.itm_Name AS Item, " & _
                                   "tbl_SalesOrderLine.sol_Rate AS Rate, tbl_SalesOrderLine.sol_Refunded AS [Refunded?], " & _
                                   "tbl_SalesOrderLine.sol_Amount AS Price, tbl_SalesOrderLine.sol_GST AS Tax, " & _
                                   "[sol_Amount]+[sol_GST] AS Total, tbl_SalesOrderLine.sol_Item, tbl_ItemDates.itd_Start " & _
                            "FROM (tbl_Enrolment RIGHT JOIN (tbl_SalesOrderLine LEFT JOIN tbl_ItemMaster " & _
                                                                                      "ON tbl_SalesOrderLine.sol_Item = tbl_ItemMaster.itm_ID) " & _
                                                        "ON (tbl_Enrolment.enl_SalesOrderLineNumber = tbl_SalesOrderLine.sol_SalesOrderLineNumber) " & _
                                                       "AND (tbl_Enrolment.enl_SalesOrderNumber = tbl_SalesOrderLine.sol_SalesOrderNumber)) " & _
                                                 "LEFT JOIN tbl_ItemDates ON tbl_Enrolment.enl_ItemDate = tbl_ItemDates.itd_ID " & _
                            "WHERE sol_SalesOrderNumber = " & SalesOrderNumber & " " & _
                            "ORDER BY sol_SalesOrderLineNumber"
    
                Debug.WriteLine(strSQLStm)
    
                Dim cmdSOLines As New OleDb.OleDbCommand(strSQLStm, gconDatabase)
                Dim datSOLines As OleDb.OleDbDataReader
    
                cmdSOLines.Connection = gconDatabase
                datSOLines = cmdSOLines.ExecuteReader
                Do Until datSOLines.Read = False
                    grdSalesLines.AddItem("")
                    grdSalesLines.set_RowHeight(grdSalesLines.Rows - 1, 480)
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdDesc, datSOLines("Item"))
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdRate, datSOLines("Rate"))
                    Try
                        grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdEnrolDate, Format(datSOLines("itd_Start"), "Short Date"))
                    Catch
                        grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdEnrolDate, "Pending")
                    End Try
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdRefunded, datSOLines("Refunded?"))
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdPrice, Format(datSOLines("Price"), "#,##0.00"))
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdTax, Format(datSOLines("Tax"), "#,##0.00"))
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdTotal, Format(datSOLines("Total"), "#,##0.00"))
                    grdSalesLines.set_TextMatrix(grdSalesLines.Rows - 1, cgrdSOL, datSOLines("Line"))
                Loop
                datSOLines.Close()
            End If
        End Sub
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  5. #5
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    You can use the datagrid without using a database. You just have to set a dataset as the source. You can then just add/modify/or remove data from the set. It actually pretty much behave like the flex grid control except that it works much better.

    Jeremy

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Also even though a DataGrid is called a DATAgrid it doesn't require a database to bind to. You can Bind to anything that Implements IList or something derived from it (i.e. ArrayList, Class..)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width