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
Solved

Lock a column in a datagrid

Posted on 2009-07-09
3
327 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

856 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