Posted on 2005-04-17
Last Modified: 2008-03-03
Hey everyone.

I'm trying to find a way to set a datagrid cell read only in VB.NET version 2003.

It would be great if someone knows how to get the control reference from a cell, and actually know the row and column number. Then i can just set the datagridtextbox to readonly from there!

something like (for example).....
dim txt as DataGridTextColumn

If there is another way to do this that someone knows about that'd be brilliant! REALLY REALLY REALLY looking for a way to do it using row and column numbers.

You might want to check this page out that i found: If anyone knows how to convert this into VB.NET code that's also an option.

Thanks in advance,


Question by:bubblesharp
    LVL 1

    Accepted Solution

    Datagrid1 is the DataGrid

    if the first column in the datagrid has a value in it, it will be set to readonly, if not it will be editable

    Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged


        Dim CurrentColumn As Integer = dgWorkerTransition.CurrentCell.ColumnNumber
        Dim CurrentRow As Integer = dgWorkerTransition.CurrentRowIndex

        'say column index 0 is an id column or something
        if CurrentColumn=0 then
               if DataGrid1.item(CurrentRow,CurrentColumn) <> "" then
               end if
        end if
    end sub

    Author Comment

    SO SIMPLE!!!!! DAMN!!!!! That's exacly what I wanted. Thank you so much

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    18 Experts available now in Live!

    Get 1:1 Help Now