Avatar of emi_sastra
emi_sastra

asked on 

Disable certain cells of datagridview.

Hi,

I use datagridview for data entry in windows form.
I want to disable certain cells so the user can not focus to those cells when clicked.
At entry mode I use :

  .SelectionMode = DataGridViewSelectionMode.CellSelect

Please help how to do it.

Thank you.

Visual Basic.NET

Avatar of undefined
Last Comment
emi_sastra
Avatar of Muhammad Kashif
Muhammad Kashif
Flag of Pakistan image

Use

DataGridView1.Columns(0).ReadOnly = True
Or
DataGridView1.Columns("ColumnName").ReadOnly = True
Or try to use
DataGridView1.Rows(0).Cells(0).ReadOnly = True
Avatar of emi_sastra
emi_sastra

ASKER

Hi MuhammadKashif,

Still could be selected for each of the cells.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Muhammad Kashif
Muhammad Kashif
Flag of Pakistan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of emi_sastra
emi_sastra

ASKER

If e.ColumnIndex = 5 Then
            DataGridView1.Item(5, e.RowIndex).Selected = False
            DataGridView1.Item(6, e.RowIndex).Selected = True 'THIS ONE SHOULD BE REMOVED
End If

I get the idea now.

Thank you very much for your help.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo