How to prevent DataGrid cell editing ?

G

Guest

I have a DataGrid on my Form, and I wish to disable any cell editing.
For example; when the user clicks on a cell, the cell become editable by
changing its color to gray and context menu is shown on muse right mouse
click.
I do not want the enable this cell context menu (I have my own context menu)
and I do not want the cell to change it's color. I want that on any click -
the entire row will be selected.
There are some other cases where the cell become editable, and I want to
prevent them all.
I did not find any event that I can hook to for that.

Can any guru in here tell how to prevent any kind of cell editing in the
DataGrid?
 
G

Gary Chang[MSFT]

Hi Sharon,

I think most of your problems could be resolved by George Shepherd's
Windows Forms FAQ:
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx

The corresponding items is as the following ones:

5.7 How do I prevent a click into the grid highlighting a cell?

5.11 How can I select the entire row when the user clicks on a cell in the
row?

5.18 How can I prevent a particular cell from being editable?

5.41 How can I make my grid never have an active edit cell and always
select whole rows (as in a browser-type grid)?

5.87 How can I prevent all the cells in my DataGrid from being edited
without deriving GridColumnStyle?


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
G

Guest

Thanks Gary for your replay,
I setting my dataGrid with the dataSet by:
m_DataSet = new myDataSet();// myDataSet is created by a XSD schema.
DataTable defectsTable = m_DataSet.Tables["Defects"]
myDataGrid.DataSource = new DataView(defectsTable);

All my cells are not editable, but in same cases the TexBox cells get in
edit mode while the text can not be changed, but the cell become gray and a
default context menu is shown overriding my own.

For the Windows Forms FAQ:
5.7 - Not good for me because then the user can do nothing with the grid.
5.11 - Doing that.
5.18 - Done that, not solving my problem,.
5.41 - Like 5.18, not solving my problem.
5.87 - Why should I do that?! and in my case the rows are added on runtime
so this function will have to used at any row adding. I did it but the
Control.Count is always 2 and this 2 are the scrollbars.

I'll be very happy if you have any more suggestions.
 
G

Gary Chang[MSFT]

Hi Sharon,
All my cells are not editable, but in same cases the
edit mode while the text can not be changed, but the
cell become gray and a default context menu is shown
overriding my own.

For the Windows Forms FAQ:
5.7 - Not good for me because then the user can do
nothing with the grid.

Since the highlightening of the selected cell is a built-in feature of the
standard Winform datagrid control, I am afraid I don't have another idea
than the above one

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
G

Guest

Hi Gary,

If the highlighting of the selected cell is a built-in feature of the
standard Winform datagrid control, maybe I can drived from this control and
do something about it by overriding some functionally.

Maybe you have any suggestion in that direction ?

highlighting
 
G

Gary Chang[MSFT]

Hi Sharon,
If the highlighting of the selected cell is a built-in feature
of the standard Winform datagrid control, maybe I can
drived from this control and do something about it by
overriding some functionally.

If you would like to implement your own custom datagrid control, I suggest
you consult it in a more appropriate managed newgroup, you'd get better and
quicker help there:

microsoft.public.dotnet.framework.windowsforms.controls


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top