Results 1 to 3 of 3

Thread: Specify which datagridview column to put into

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2015

    Post Specify which datagridview column to put into


    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

    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.

    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
    South UK

    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
    Join Date
    Oct 2010

    Re: Specify which datagridview column to put into

    Here is one method.
    Dim row As New DataGridViewRow
    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


Click Here to Expand Forum to Full Width