473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1644
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
2127
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
1973
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
2392
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
2756
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
4031
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
319
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
7225
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
7324
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
7382
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...
1
7042
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
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.