|
-
Dec 17th, 2002, 10:19 AM
#1
Thread Starter
Lively Member
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?
-
Dec 17th, 2002, 11:02 AM
#2
Registered User
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.
-
Dec 19th, 2002, 03:14 AM
#3
Thread Starter
Lively Member
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.
-
Dec 19th, 2002, 04:49 PM
#4
Hyperactive Member
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
-
Dec 19th, 2002, 04:52 PM
#5
Addicted Member
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
-
Dec 19th, 2002, 04:57 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|