?
Solved

datagrid read only cell HELPPPPPPPPPPPPPPPPPPPPPP

Posted on 2005-04-17
2
Medium Priority
?
883 Views
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
txt=Datagrid1.item(row,column).control

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: http://www.akadia.com/services/dotnet_datagrid_disable_cell.html. If anyone knows how to convert this into VB.NET code that's also an option.

Thanks in advance,

Simon


0
Comment
Question by:bubblesharp
2 Comments
 
LVL 1

Accepted Solution

by:
undyshelts earned 500 total points
ID: 13803981
Assume:
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

    DataGrid1.ReadOnly=false

    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
                 DataGrid1.ReadOnly=true
           end if
    end if
end sub
0
 

Author Comment

by:bubblesharp
ID: 13803984
SO SIMPLE!!!!! DAMN!!!!! That's exacly what I wanted. Thank you so much
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 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