Results 1 to 5 of 5

Thread: DataGridView Cell Borders

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Smile DataGridView Cell Borders

    Hi all

    Have this code so that when a checkbox in a column of my datagridview is checked, then the corresponding cell in column 2 (of the same row the check box is in) will turn blue with font color white.

    Code:
     If DataGridView1.Columns(e.ColumnIndex).Name = "Column15" Then
                'Choose the color based on the checkbox cell value.
                Dim clr12 As Color
                If DataGridView1.Rows(e.RowIndex).Cells("Column10").Value = True Then
                    clr12 = Color.Blue
                End If
    
                DataGridView1.Rows(e.RowIndex).Cells("Column2").Style.BackColor = Color.Blue
                DataGridView1.Rows(e.RowIndex).Cells("Column2").Style.ForeColor = Color.White
    I'd also like to add a line so that as well as the cell going blue, the bottom border of the cell disappears, so cellborderstyle = none.

    Can't get it to work

    Help is appreciated,

    M

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: DataGridView Cell Borders


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: DataGridView Cell Borders

    Hi Kevin, thanks for the link.

    Do you know of any way that I can copy and paste data, for example from an excel spreadsheet or other table format, into my DataGridView and it will paste into the correct cells so its layout remains the same, eg Column A will be filled with all relevant data etc etc...is there a property on the datagridview which would allow this?

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: DataGridView Cell Borders

    Quote Originally Posted by MacShand View Post
    Hi Kevin, thanks for the link.

    Do you know of any way that I can copy and paste data, for example from an excel spreadsheet or other table format, into my DataGridView and it will paste into the correct cells so its layout remains the same, eg Column A will be filled with all relevant data etc etc...is there a property on the datagridview which would allow this?
    No, the DataGridView does not understand copy/paste even simply data. A DataGridView with the right code can do copy/paste but not on it's own. Best to look to another solution.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: DataGridView Cell Borders

    Hi there...sorry to bring this thread back up, but have now come to re-try this, and my ignorance means I can't get it to work ....

    can you advise on the code I should use? So when the checkbox is ticked, the cell goes blue and the gridline on the bottom of that cell gets removed.

    Many thanks for your continued help, Kevin!

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