473,396 Members | 1,766 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,396 software developers and data experts.

Disable editing on a row basis on DataGrid (winforms)

I have a datagrid that I want to be able to allow me to edit only the first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you
Jun 5 '07 #1
6 8620
I forgot to say I use VB.NET 2003

"Gentian Hila" wrote:
I have a datagrid that I want to be able to allow me to edit only the first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you
Jun 5 '07 #2
Gentian,

AFAIK impossible, the datagrid was greath but in fact very poor in use,
therefore came the datagridview

Cor

"Gentian Hila" <Ge*********@discussions.microsoft.comschreef in bericht
news:23**********************************@microsof t.com...
>I forgot to say I use VB.NET 2003

"Gentian Hila" wrote:
>I have a datagrid that I want to be able to allow me to edit only the
first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you

Jun 5 '07 #3
Thanks. But that is only for Visual Studio 2005 right? I am using 2003 and it
may take a while before I do that transition.

In the meantime what can I do with 2003?

"Cor Ligthert [MVP]" wrote:
Gentian,

AFAIK impossible, the datagrid was greath but in fact very poor in use,
therefore came the datagridview

Cor

"Gentian Hila" <Ge*********@discussions.microsoft.comschreef in bericht
news:23**********************************@microsof t.com...
I forgot to say I use VB.NET 2003

"Gentian Hila" wrote:
I have a datagrid that I want to be able to allow me to edit only the
first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you


Jun 5 '07 #4
Gentian Hila wrote:
I have a datagrid that I want to be able to allow me to edit only the
first two rows and all the other rows to be read-only.
Assuming the DataGrid in VS2003 works the same as in VS2005 (I don't know
whether it does or not, I only have VS2005 installed), you should be able to
achieve this by:

- declaring a class that inherits from Windows.Forms.DataGridTextBoxColumn

- in the class, override the Edit method. Add code that calls into the base
class if the rowNum is one you want to be editable, or simply returns
without doing anything if you want the column to be read-only.

- when initialising the grid, create a new Windows.Forms.DataGridTableStyle
object.

- for each column in the grid, add a new instance of your class from above
to the DataGridTableStyle object. Make sure you set the MappingName property
of the object to match the underlying column name in your DataTable, and
also set the HeaderText, Width, Alignment and anything else you need.

- once you've added all your columns, add the DataGridTableStyle object to
the DataGrid.TableStyles collection.

- finally, set the DataGrid's DataSource.

Hopefully that will do what you want!

--

(O)enone
Jun 5 '07 #5
Maybe you can set two datagrids above each other. However the problem stays
that read only and things like that with a datagrid in 2003 is done with the
dataview.

Cor

"Gentian Hila" <Ge*********@discussions.microsoft.comschreef in bericht
news:D5**********************************@microsof t.com...
Thanks. But that is only for Visual Studio 2005 right? I am using 2003 and
it
may take a while before I do that transition.

In the meantime what can I do with 2003?

"Cor Ligthert [MVP]" wrote:
>Gentian,

AFAIK impossible, the datagrid was greath but in fact very poor in use,
therefore came the datagridview

Cor

"Gentian Hila" <Ge*********@discussions.microsoft.comschreef in bericht
news:23**********************************@microso ft.com...
>I forgot to say I use VB.NET 2003

"Gentian Hila" wrote:

I have a datagrid that I want to be able to allow me to edit only the
first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you



Jun 6 '07 #6
Hi:

If I recall correctly, the 2003 DataGrid was originally designed by
componentone, and should have a rowcolchange event, row property, and
AllowUpdate property?

If so, then you check which row you are in in the rowcolchange event, then
set the allowupdate property accorindingly.

hope this helps,
--
Doug.

"Gentian Hila" wrote:
I forgot to say I use VB.NET 2003

"Gentian Hila" wrote:
I have a datagrid that I want to be able to allow me to edit only the first
two rows and all the other rows to be read-only.

How can I do that? Any insight is highly appreciated.

I have spent couple of days on research but no luck so far.

Thank you
Aug 4 '07 #7

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

Similar topics

4
by: Terry | last post by:
Hey, Having somewhat of an issue, I have a datagrid which is giving me issues. The Datagrid is setup for the user to double click the row, the row is selected and data within that row populates a...
3
by: Jianfeng Chen | last post by:
no problem with vb6, but what's wrong with the datagrid binding with vb.net? thanks.
4
by: Jerry | last post by:
Hi, I have an app which retrieves data from a sql server table and displays it on a datagrid. If 2 sessions of this app are running and 2 users try to update the same record at about the same...
2
by: Agnes | last post by:
In myDatagrid, there is 3 columns, account code, debit,credit. If the user input some particular a account code in column1 , i need to based on the contect of column1, to disable...
1
by: johnb41 | last post by:
I have a datagrid that successfully allows editing and updating (with dataadapter.update command). I want the user to be able to edit the "text" in the datagrid, but i DON'T want the user to be...
1
by: Gidi | last post by:
Hi, Is it possible to Disable editing of one specific cell in one specific row in dataGrid? Thanks, Gidi.
0
by: adh | last post by:
Hi, I'm looking how to place a Combobox above a cell (current row or new datagrid.row.cell) for datagrid edditing, and exchange data between the cell/Combobox (or textbox)(WinForms!) Please...
7
by: Rico | last post by:
Hello, I have a Datagrid with two rows, "Product Description" and "Serial Number". I want the user to be able to add / edit the serial number, but not the Product Description. In fact, I don't...
0
by: =?Utf-8?B?R2VudGlhbiBIaWxh?= | last post by:
I have a datagrid that I want to be able to allow me to edit only the first two rows and all the other rows to be read-only. How can I do that? Any insight is highly appreciated. I have spent...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.