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

DataGrid column Locked Property

In VB6, any column in the DataGrid had a Locked Property. I can not find
this property in the .Net DataGrid. Where is this property or what is the
replacement property?
Nov 20 '05 #1
2 2205
Hi David,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to make one of the
column in the datagrid readonly in VB.NET
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think we can use the DataGridTableStyle and DataGridColumnStyle to do
the job.

Here is simple code snippet.

Dim ts As DataGridTableStyle
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'fill data into dataset11
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
'add a new DataGridTableStyle
ts = New DataGridTableStyle
ts.MappingName = Me.DataSet11.Employees.TableName
Me.DataGrid1.TableStyles.Add(ts)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'get the Address column and set its readonly property to true so that we
are not able to modify the Address column.
Dim cs As DataGridColumnStyle = ts.GridColumnStyles("Address")
cs.ReadOnly = True
End Sub
Please apply my suggestion above and let me know if it helps resolve your
problem.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Peter,

I can make your example work with some additional coding.

Thanks,
Dave

""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:V0**************@cpmsftngxa10.phx.gbl...
Hi David,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to make one of the
column in the datagrid readonly in VB.NET
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think we can use the DataGridTableStyle and DataGridColumnStyle to do
the job.

Here is simple code snippet.

Dim ts As DataGridTableStyle
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'fill data into dataset11
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
'add a new DataGridTableStyle
ts = New DataGridTableStyle
ts.MappingName = Me.DataSet11.Employees.TableName
Me.DataGrid1.TableStyles.Add(ts)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'get the Address column and set its readonly property to true so that we
are not able to modify the Address column.
Dim cs As DataGridColumnStyle = ts.GridColumnStyles("Address")
cs.ReadOnly = True
End Sub
Please apply my suggestion above and let me know if it helps resolve your
problem.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3

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

Similar topics

5
by: Jean Carlo | last post by:
Hello guys I`m developing a windows form that contain one Datagrid. In this datagrid I insert a checkBox Column. I need to get all rows where checkbox is checked by user. How do I get this...
5
by: Alpha | last post by:
I set the Locked property = True for the datagrid but in run time the width shriks automatically making the windows looking messy. How do I fix this so it would stay the same as in the designer...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
4
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
3
by: Lars Netzel | last post by:
(applies to Windows Form .NET 2003) I'm filling a datagrid from a Datatable and applying a DataGridStyle. The Source Fields are "Name", "Value", "Locked" and the Style's Columns are "Name",...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.