473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

System.Windows.Forms.DataGrid question.

Hello everyone.
Normally, the cell of the System.Windows.Forms.DataGrid could be inputed.
How can I let the cells only show something and not be inputed?

Jul 21 '05 #1
3 1638
Hi Steven,

The DataGrid doesn't have that kind of control, but a DataView does. Assuming you use the first DataTable in a DataSet called 'ds'

ds.Tables[0].DefaultView.AllowNew = false;
ds.Tables[0].DefaultView.AllowEdit = false;

AllowNew set to false prevents the blank new line at the bottom.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #2
Rod

"Steven.Xu" <St******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Hello everyone.
Normally, the cell of the System.Windows.Forms.DataGrid could be inputed.
How can I let the cells only show something and not be inputed?


by using DataGridTableStyles you can make individual columns read only
Jul 21 '05 #3
You can control that by DataGridColumnStyle, you can reach a specific column
style object and control its readonly property:

yourGrid.TableStyles["TableName"].GridColumnStyles["ColumnName"].ReadOnly =
true;

or you can higher control when you access the TextBox control hosted in the
cell, accessing a TextBox properties of a cell will be like this:

((DataGridTextBoxColumn)(this.yourGrid.TableStyles["TableName"].GridColumnStyles[""])).TextBox.ReadOnly = true;

Note: To reach the text box, you reach first the ColumnStyle object and cast
it to DataGridTextBoxColumn refrence to be able to access "TextBox" property
that allows you to control the textbox objects hosted in that column cells.

Hope that work with you, good luck
---
Ahmed Ghozzy
"Steven.Xu" wrote:
Hello everyone.
Normally, the cell of the System.Windows.Forms.DataGrid could be inputed.
How can I let the cells only show something and not be inputed?

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: max | last post by:
I can generate this error by NOT assigning a tableName to the view: at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit() Is there any possibility of...
2
by: Tom P | last post by:
I'm trying to use DataGrid.HitTestInfo in my OnMouseDown event but firstly I cannot see it in Intellisense, secondly when I try to use it I get strange 'COMPILE' errors when building the app I'll...
3
by: scott | last post by:
hi all, hope some one can help iv created a datagrid that points to a DataView. the data view takes in a DataTable. The DataTable then adds the columns using DataColumn. All fine so far. ...
4
by: elime | last post by:
Hi all I load datas from an SQL server to a Datagrid. The datagrid columns are basically read only but one column is not -> the checkboxcolum. The user needs to be able to check or uncheck this...
1
by: Dmitry V. Markin | last post by:
Good day! Here is my problem: I need to have a radiobutton column in my DataGrid for a representation of a bool column, where only row can be checked at one time(only one value in bool column...
6
by: Steven.Xu | last post by:
Hello everyone. Normally, the cell of the System.Windows.Forms.DataGrid could be inputed. How can I let the cells only show something and not be inputed?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.