Solved

Lock a column in a datagrid

Posted on 2009-07-09
3
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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