Home All Groups Group Topic Archive Search About

Migration of MSFLEXGRID to DATAGRID in vb.net...

Author
9 Jan 2006 4:47 PM
zoneal
Hi,
I am involved in the process of migrating vb(6.0) application to
vb.net. My application contains only vb controls namely MSFLEXGRID. I
want to migrate my application to vb.net completely without any
OCX(MSFLEXGRID) controls.

I found datagrid to be an equivalent control of MSFLEXGRID in vb.net.
I am unable to find an equivalent method & property of datagrid in
vb.net. Please provide some examples which helps me to migrate the
MSFLEXGRID to datagrid in vb.net easily.

Below vb code shows flexgrid properties:

Sub InitCallInfo()
On Error GoTo err_handler

   flexgrid.Rows = 50

   With flexgrid
        .ColWidth(0) = 900
        .ColWidth(1) = 3100
        .ColWidth(2) = 1200
        .Row = 0
        .Col = 0
        .CellFontBold = True
        .Text = "No.Calls"
        .Col = 1
        .CellFontBold = True
        .Text = "Call Type"
        .Col = 2
        .CellFontBold = True
        .Text = "Amount"
    End With


   cnPRU.sp_GetWTNDetail CurrentAcct     'cnPRU - SQL connection
   Set rsCalls = cnPRU.LastQueryResults

   j = 0

   Do While Not rsCalls.EOF
      j = j + 1
      flexgrid.Row = j
      With flexgrid
           .Col = 0
           .CellFontBold = True
           .Text = rsCalls("NumCalls")
           .Col = 1
           .CellFontBold = True
           .Text = rsCalls("Description")
           .Col = 2
           .CellFontBold = True
           .Text = Format(rsCalls("CallDollars"),
"$#,##0.00;($#,##0.00")
      End With
      rsCalls.MoveNext

    Loop

  rsCalls.Close

  flexgrid.Rows = j + 2 'set total number of rows
  flexgrid.Row = j + 1
  With flexgrid
       .Col = 0
       .CellBackColor = &HC0FFFF
       .CellFontBold = True
       .Text = intNumCalls
       .Col = 1
       .CellBackColor = &HC0FFFF
       .CellFontBold = True
       .CellFontItalic = True
       .Text = "Total Calls"
       .Col = 2
       .CellBackColor = &HC0FFFF
       .CellFontBold = True
       .Text = Format(curUBIC, "$#,##0.00;($#,##0.00")
  End With

Exit_Procedure:
    Exit Sub

err_handler:
    strErr = "Y"
    MsgBox Err.Description
    cnPRU.sp_InsertError1 Err.Number, Err.Description, "frmWorklist",
"InitCallInfo"
    Resume Exit_Procedure


End Sub

Please provide equivalent properties of datagrid in vb.net to achieve
the same output.

Thank you!

Author
9 Jan 2006 4:53 PM
Cor Ligthert [MVP]
Zoneal,

Be aware that the DataGrid uses forever a datasource which is in your case a
DataTable/Dataview/DataTable.Defaultview.

Have than a look at our website. The datagrid part is full of samples which
are completely stand alone. (The one that are not standalone can you use as
well by the way, however than with creating the datatable as in the other
samples)

http://www.vb-tips.com/default.aspx

I hope this helps,

Cor