Solved

Lock a column in a datagrid

Posted on 2009-07-09
3
326 Views
Last Modified: 2012-05-07
I have a datagrid in vb6.  When I pull up the records in the grid, I want to block the users from editing column 1,2 and 6.  How do I do this, if possible?

0
Comment
Question by:al4629740
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
lppperes earned 250 total points
ID: 24820559
You can try using the event BeforeColUpdate. Check the ColIndex. If it is one of the forbbiden columns, cancel the update.

Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex as Integer, OldValue as Variant, Cancel as Integer)
    If ColIndex = 1 Or ColIndex = 2 Or ColIndex = 6 Then
        Cancel = 1
    End If
End Sub

Open in new window

0
 
LVL 2

Expert Comment

by:lppperes
ID: 24820593
Using the event BeforeColEdit you can achieve an user experience even better, cause the value in the column doesn´t get to change.
0
 

Author Comment

by:al4629740
ID: 24820599
thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question