?
Solved

Lock a column in a datagrid

Posted on 2009-07-09
3
Medium Priority
?
330 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 1000 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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

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