Results 1 to 5 of 5

Thread: Datagrid

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    192

    Datagrid

    Me again about grids:
    I have in vb6 mobile pocket pc :

    GridCtrl1.Row
    GridCtrl1.AddItem
    GridCtrl1.Row = GridCtrl1.Rows - 1
    GridCtrl1.Col = 1
    GridCtrl1.ColWidth(0) = 500
    -------------------------
    I got on another forum how to use Grid command:

    DirectCast(DataGrid1.DataSource,System.Data.DataTable).Rows.Item(index)
    The cast depends on the type of your DataSource
    -------------------------
    I tried like this:
    directcast(DataGrid1).Rows.item etc.

    But show me error :
    Syntax error in cast operator; two arguments separated by comma are required.
    -------------------------

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Datagrid

    Hi,
    again - instead of trying to translate VB6 to .Net, look at the .Net way of doing it. Can you not bind your grid to a datasource?

    Similar to...
    Code:
    Dim objAdapter As SqlCeDataAdapter
            Dim objDataset As Data.DataSet
            Dim strSQL As String
    
            strSQL = "SELECT * FROM Accounts"
    
            objAdapter = New SqlCeDataAdapter(strSQL, "Data Source = \My Documents\test.sdf")
    
            objDataset = New Data.DataSet()
            objAdapter.Fill(objDataset, "Accounts")
    
            dgAccounts.DataSource = objDataset.Tables("Accounts")

    Also take a look at http://samples.gotdotnet.com/quickst...pactFramework/ and 'data' on the left column - quite a few examples there
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    192

    Re: Datagrid

    Am actually upgrading from eVB to .net 2005, and am not friendly really with visual studio.

    I had used commands
    gridctrl1.Row
    gridctrl1.Rows
    gridctrl1.Col
    gridctrl1.LeftCol
    gridctrl1.clear
    .colwidth
    .rowheight
    .rowpos
    .colpos

    which i cannot fing their eqivalent in vb 2005 , i.e using datagrid

    Even for a label in which i used label1.move , in 2005 i can't get the label1.setbounds property.

    Can you help me out.

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Datagrid

    The reason why you keep being told it is a re-design and re-write is that in a lot of cases, there is no equivalent statements in .Net for eVB statements.

    To set the location of a control
    lvEnquiries.Location = New System.Drawing.Point(2 , 67)

    I did a webcast on MSDN on this subject a while ago that may help and wrote an article for MSDN on the same subject here

    They are probably well out of date now, but may help.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    192

    Re: Datagrid

    I found example how to select column or row!

    Private Sub SetCellValue(ByVal myGrid As DataGrid)
    Dim myCell As New DataGridCell()
    myCell.RowNumber = myGrid.CurrentRowIndex
    myCell.ColumnNumber = 1
    myGrid(myCell)= "New Value"
    End Sub

    Private Sub GetCellValue(ByVal myGrid As DataGrid)
    Dim myCell As New DataGridCell()
    Dim strValue As string
    myCell.RowNumber = myGrid.CurrentRowIndex
    myCell.ColumnNumber = 1
    strValue = myGrid(myCell)
    End Sub

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