Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to learn how to load a DataGrid for my job 1

Status
Not open for further replies.

cal555

Programmer
May 5, 2006
71
US
Hi,
I am tring to find out how to code a DataGrid control. I have been asked to incorperate this in a project on my job. I have looked alover the internet and in books and can not find what I need. One of the few things I found uses a Data control. I want to use this with OLEBD connection strings and ADO recod sets. Could someone show me how to load a DataGrid, or point me to a site that would. Also, If it I dont know if it matters but we are connecting to SQL Server.
Thank you

 
I don't know if loading a data grid is anything like loading a MSFlexGrid, so I don't know how applicable this is. But I would think it would be somewhat similar.

Code:
'Number of columns
frmManWildcardResults.FlexWildMan.Cols = 7
'Number of rows from recordset
frmManWildcardResults.FlexWildMan.Rows = rsWildcard.RecordCount + 1
'1 fixed row for the headers for the columns
frmManWildcardResults.FlexWildMan.FixedRows = 1
'No fixed columns
frmManWildcardResults.FlexWildMan.FixedCols = 0
'Start at row 0
frmManWildcardResults.FlexWildMan.Row = 0
'These are the column headers for the grid 
frmManWildcardResults.FlexWildMan.FormatString = "Customer |Location|<Part Number|Rev|<Date|<Job Number|Comments"
'Set the column widths for each column
frmManWildcardResults.FlexWildMan.ColWidth(0) = 1300 'customer
frmManWildcardResults.FlexWildMan.ColWidth(1) = 0 'location
frmManWildcardResults.FlexWildMan.ColWidth(2) = 2000 'partnumber
frmManWildcardResults.FlexWildMan.ColWidth(3) = 550 'rev
frmManWildcardResults.FlexWildMan.ColWidth(4) = 2000 'date
frmManWildcardResults.FlexWildMan.ColWidth(5) = 1800 'job number
frmManWildcardResults.FlexWildMan.ColWidth(6) = 3500 'comments
rsWildcard.MoveLast
rsWildcard.MoveFirst

frmManWildcardResults.lblManWild.FontBold = True
frmManWildcardResults.lblManWild = "There are " & rsWildcard.RecordCount & " stencils that match " & txtSPN & "."

DoEvents
frmManWildcardResults.MousePointer = 11
'Loop thru the recordset and populate the flexgrid
With rsWildcard
   frmManWildcardResults.FlexWildMan.Row = 1
   For X = 1 To rsWildcard.RecordCount
    On Error Resume Next
    frmManWildcardResults.FlexWildMan.Col = 0
    frmManWildcardResults.FlexWildMan.Text = rsWildcard("customer")
    frmManWildcardResults.FlexWildMan.Sort = 0
    'frmManWildcardResults.FlexWildMan.Font.Size = 8
    frmManWildcardResults.FlexWildMan.Col = 1
    frmManWildcardResults.FlexWildMan.Text = rsWildcard("storageloc")
    frmManWildcardResults.FlexWildMan.Col = 2
    frmManWildcardResults.FlexWildMan.Text = rsWildcard("stencilpartnumber")
    frmManWildcardResults.FlexWildMan.Col = 3
    frmManWildcardResults.FlexWildMan.Text = rsWildcard("stencilrev")
    frmManWildcardResults.FlexWildMan.Col = 4
    frmManWildcardResults.FlexWildMan.Text = Nz(rsWildcard("date"), "")
    frmManWildcardResults.FlexWildMan.Col = 5
    frmManWildcardResults.FlexWildMan.Text = Nz(rsWildcard("jobnumber"), "")
    frmManWildcardResults.FlexWildMan.Col = 6
    frmManWildcardResults.FlexWildMan.Text = Nz(rsWildcard("comments"), "")
    .MoveNext
'Add another row if we have more records.
    If frmManWildcardResults.FlexWildMan.Row + 1 < frmManWildcardResults.FlexWildMan.Rows Then
        frmManWildcardResults.FlexWildMan.Row = frmManWildcardResults.FlexWildMan.Row + 1
    End If
  
  Next
End With

I hope this helps some.
 
Thanks for taken the time to do this it is a big help.
Thank you
 
Thanks for the star! I hope you got your problem resovled.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top