473,322 Members | 1,287 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,322 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 1629
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.