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

How to make a specific row in a datagrid to become read only?

I would like to make some of the rows in the datagrid read only according to
certain condition.
How can I make some of the rows editable while others read only in a
datagrid? Thanks!
Nov 17 '05 #1
1 3356
Hi,

For this, you can trap the row being clicked in the MouseDown event of the grid. Check for row number or its value and set the ReadOnly property of the grid to True:

Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
Dim htinfo As DataGrid.HitTestInfo

htinfo = Me.DataGrid1.HitTest(e.X, e.Y)

Dim r As Integer

r = htinfo.Row

If r = 2 Then

Me.DataGrid1.ReadOnly = True

Else

Me.DataGrid1.ReadOnly = False

End If

End Sub

However, if you wish to make a row readonly when the grid is loaded, you can inherit from DataGridTextBoxColumn and create a customized Column Style
yourself, then you can override Edit method. Finally determine the value of the current edit cell and disable the edit function. See the following article on implementing a custom column style:

http://msdn.microsoft.com/library/de...classtopic.asp

Hope this helps.

Thanks

Mona [GrapeCity]

"ywchan" <yw****@gmail.com> wrote in message news:el**************@TK2MSFTNGP09.phx.gbl...
I would like to make some of the rows in the datagrid read only according to
certain condition.
How can I make some of the rows editable while others read only in a
datagrid? Thanks!

Nov 17 '05 #2

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

Similar topics

2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
3
by: Pedor | last post by:
I want to display only data in the datagrid for specific records having a common or identical data in a column. How do you do this programmaticaly using combination of the datagrid object,...
15
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
4
by: NH | last post by:
Hi, I just cannot get this to work. I want to make a cell editable in a datagrid only if the value of another cell is something specific. I am able to capture the value of the other cell via the...
6
by: Eric Broers | last post by:
LS, Assume I have a datagrid, which is filled by an SQL statement (Select * from Customer). The Customers table contains 4 columns and 10 rows. Now, I want to fill 10 strings with the datagrid...
1
by: Don | last post by:
George Shepherd's great Windows Forms FAQ has this article about creating a datagrid with no active cell: http://www.syncfusion.com/faq/winforms/search/856.asp Unfortunately, this only works...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: karups | last post by:
Hi I have binded a dataset to my datagrid. Datagrid is present inside a >DIV></DIVtag of specific height. Only 5 records will be visible at a time when i edit the 10th record, the page...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.