VS 2012 Specify which datagridview column to put into-VBForums
Results 1 to 3 of 3

Thread: Specify which datagridview column to put into

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    3

    Post Specify which datagridview column to put into

    Hello

    I am having some trouble with a datagridview in my program

    i am using this command to add some items to my columns in the datagridview

    Code:
    datagridview1.Rows.Insert(0, .Item(0), .Item(1))
    BUT i have 10+ columns and, lets say i wanted to add something to column 4 and not 1 and 2 as i do in the code above

    I have tried this, but this just leaves the first columns blank which doesnt work for me.

    Code:
    datagridview1.Rows.Insert(0, "", "", .Item(0), .Item(1))
    With that code i can put my items into column 3 and 4, but this also erases whats already in column 1 and 2

    Any help?

  2. #2
    Frenzied Member Bulldog's Avatar
    Join Date
    Jun 2005
    Location
    South UK
    Posts
    1,950

    Re: Specify which datagridview column to put into

    You can insert data by cell coordinate, e.g. assuming the row already exists;

    DataGridView1.Rows(5).Cells(3).Value = "Hello"


    • If my post helped you, please Rate it
    • If your problem is solved please also mark the thread resolved

    I use VS2015 (unless otherwise stated).
    _________________________________________________________________________________
    B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
    I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.

  3. #3
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Specify which datagridview column to put into

    Here is one method.
    Code:
    Dim row As New DataGridViewRow
    row.CreateCells(DataGridView1)
    row.Cells(4).Value = "something"
    DataGridView1.Rows.Insert(0, row)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.