Solved

Configure a DataGrid for limited user access

Posted on 2007-04-04
2
237 Views
Last Modified: 2010-04-23
Hi,

I have a datagrid that is bound to a datatable in code and I am using DataGridTableStyles to format the grid just the way I want it to look. I don't want the user to be able to add any new rows so I set the dagatgrid.ReadOnly property to TRUE. However, there is one column of rows that I do want the user to be able to change. In this case I was thinking the user could type a new number in a particular cell and then click on a button to store the changes back to the original database table.

So, is there any way to prevent the user from adding rows to a datagrid and keep the entire datagrid as Read-)nly except for one column?

Thanks,
Charlie
0
Comment
Question by:charlieb01
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
mytonytiger earned 500 total points
ID: 18853959
I assume you are using VS 2003:

To prevent the users from adding rows, you have to set it in the datatable being used as a datasource.
An example is:  

Dim ds as new dataset
'---------------------
'Fill dataset here
'---------------------

'Now turn off the new row
ds.tables(0).DefaultView.AllowNew = False
datagrid1.datasource = ds.tables(0)

0
 
LVL 5

Expert Comment

by:mytonytiger
ID: 18853969
The Second part of your question is about locking down all but one column:

You can set each individual column of the datatable as readonly.

ds.tables(0).Columns(0).readonly = True
ds.tables(0).Columns(1).readonly = True
ds.tables(0).Columns(2).readonly = True
'etc....
ds.tables(0).Columns(3).readonly = false ' This one is editable.



Hope that helps
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

11 Experts available now in Live!

Get 1:1 Help Now