Avatar of ardixiv
ardixiv

asked on 

datatable as column in datatable

Hi all,

I have a datatable which contains several columns of type integer, string, boolean, the last record of each row should be of type datatable.  Is this possible, and if yes, whats the solution?

thanks!
ardi
Visual Basic.NET

Avatar of undefined
Last Comment
iboutchkine
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ardixiv
ardixiv

ASKER

strange:

this is what I do:

plantabel.columns.add("NAME", gettype(String))
plantabel.columns.add("PAGES", gettype(datatable))

temptabel.columns.add("X", gettype(integer))
tembtabel.columns.add("Y", gettype(integer))
temptabel.columns.add("ROTATION, gettype(integer))

plantabelrow = plantabel.newrow
temptabelrow = temptabel.newrow


plantabelrow.item("NAME") = "file0001.tif"
temptabelrow.item("X") = 840
temptabelrow.item("Y") = 1189
temptabelrow.item("ROTATION") = 90
temptabel.rows.add(temptabelrow)
plantabel.rows(0).item("PAGES") = temptabel
plantabel.rows.add(plantabelrow)


when I set up a datagrid with datasource plantabel.rows(0).item("PAGES") then The table is empty.
Avatar of iboutchkine
iboutchkine

Here I managed to write datagrid within datagrid. Just make it look nicer

 Dim cn As OleDbConnection
    Dim sConn As String = _
     "Provider=Microsoft.Jet.OLEDB.4.0;" & _
     "Data Source=C:\TestDB\TestDB.mdb;"

    Dim ds As DataSet
    Dim dsI As DataSet
    Dim da As OleDbDataAdapter
    Dim da1 As OleDbDataAdapter
    Dim sSQL As String = "SELECT * FROM Test"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cn = New OleDbConnection(sConn)

'fill datagrid that we will insert to the main datagrid
        dsI = New DataSet()
        da1 = New OleDbDataAdapter("select * from ITH", sConn)
        da1.Fill(dsI, "ITH")
        dgI.DataSource = dsI
        dgI.DataMember = "ITH"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ds = New DataSet()
        da = New OleDbDataAdapter("select * from test", sConn)
        da.Fill(ds, "Test")

        dg.PreferredRowHeight = dgI.Height
'fill main datagrid
        dg.DataSource = ds
        dg.DataMember = "Test"
        'Add ComboBox to the Control collection of the DataGrid.
        dg.Controls.Add(dgI)

    End Sub

    Private Sub dg_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles dg.Paint
        If dg.CurrentCell.ColumnNumber = 3 Then
            dgI.Width = dg.GetCurrentCellBounds.Width
        End If
    End Sub

    Private Sub dg_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg.CurrentCellChanged
        If dg.CurrentCell.ColumnNumber = 3 Then
            dgI.Visible = False
            dgI.Width = 0
            dgI.Left = dg.GetCurrentCellBounds.Left
            dgI.Top = dg.GetCurrentCellBounds.Top
            dgI.Text = dg.Item(dg.CurrentCell) & ""
            dgI.Visible = True
        Else
            dgI.Visible = False
            dgI.Width = 0
        End If
    End Sub
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo