Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Nested DataGridView Problem

Nested DataGridView Problem

Scheduled Pinned Locked Moved Visual Basic
databasehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ccotton333
    wrote on last edited by
    #1

    Hey Guys, I found an article that helped me nest a datagridview within a datagridview; however, the nested datagridview doesn't scroll. I was wondering if someone could tell me what I'm missing. Here is my code, which works great when the datacolumn is frozen. Dim dt As New DataTable Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sql As String = "SELECT distinct upc,sku,style,class_id,department,vendor FROM items a" Dim adapter As New Odbc.OdbcDataAdapter(sql, New Odbc.OdbcConnection("DSN=tdprod;uid=ccotton;pwd=ccotton")) If Not dt.Columns.Contains("upc") Then dt.Columns.Add("upc") If Not dt.Columns.Contains("sku") Then dt.Columns.Add("sku") If Not dt.Columns.Contains("style") Then dt.Columns.Add("style") If Not dt.Columns.Contains("class_id") Then dt.Columns.Add("class_id") If Not dt.Columns.Contains("department") Then dt.Columns.Add("department") If Not dt.Columns.Contains("vendor") Then dt.Columns.Add("vendor") adapter.Fill(dt) DataGridView1.DataSource = dt DataGridView1.Columns("upc").Frozen = True DataGridView1.Columns("sku").Frozen = True DataGridView1.Columns("style").Frozen = True DataGridView1.ReadOnly = True End Sub Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting If e.RowIndex >= 0 Then If e.ColumnIndex >= 0 Then If e.ColumnIndex = 2 Then Dim list As New DataGridView list.ReadOnly = True Dim helpdt As New DataTable helpdt.Columns.Add("Num") For i As Integer = 0 To 8 Dim sub_row As DataRow = helpdt.NewRow sub_row.Item("Num") = i + 1 helpdt.Rows.Add(sub_row) Next list.DataSource = helpdt DataGridView1.Rows(e.RowIndex).Height = 100 DataGridView1.Columns(e.ColumnIndex).Width = 200 list.Width = 200 list.Height = 100 DataGridView1.Controls.Add(list) D

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups