datagridview hide checkbox?

I have a datagridview checkbox column. How do I make some of them invisible? Alternatively, how do I only make specific cells checkbox?

I want a checkbox column with some cells looking empty. I already have those rows read-only.
PizpotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
To hide a datagridview-column

        DataGridView1.AutoGenerateColumns = True;
        DataGridView1.DataSource = ds;
        DataGridView1.DataMember = "TableName";
        //DataGridView1.DataMember = ds.Tables[0].TableName;

        DataGridView1.Columns[0].Visible = False;
0
PizpotAuthor Commented:
I bet you could draw over the checkboxes!?!
0
DhaestCommented:
Can you please clarify your previous comment (and the reason why it should be accepted !)
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

PizpotAuthor Commented:
Yes. A possible solution would be to draw an area of pixels over the checkboxes, and make them read-only so that they do nothing and are invisible.

The suggestion in the 2nd post, to make the whole column invisible does not answer the question. Not every row, just some!
0
PizpotAuthor Commented:
Here is what I did.  I already set these rows readonly with

DataGridView1.Rows(r).ReadOnly = True

All I needed was an array of which rows to hide the checkboxes in.
   Private Sub DataGridView1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGridView1.Paint
 
        'Hide Checkboxes:
        Dim r As Integer
        Dim rect As Rectangle
        For r = 0 To bundle_count_g - 1
            If row_status(r) = "erase" Then
                rect = DataGridView1.GetCellDisplayRectangle(8, r, True)
                e.Graphics.FillRectangle(Brushes.LightGray, rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2)
            End If
        Next r
 
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vee_ModCommented:
Closed, 300 points refunded.
Vee_Mod
Community Support Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.