Solved

Lock a column in a datagrid

Posted on 2009-07-09
3
322 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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now