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

Disable delete key over datagrid

35
hi,
i have an applicaiton in which i am using datagrid its working properly, the
problem here is if i select a row and press "Delete" Key (Key board) the row
is getting deleted. how to prevent this?? Pls reply me soon
Regards,
Suguna
Mar 7 '07 #1
3 2182
radcaesar
759 Expert 512MB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' Retrieve data from the database.
Dim con As New
SqlConnection("server=MyServer;uid=sa;pwd=sa;datab ase=northwind")
Dim daEmp As New SqlDataAdapter("Select * From customers", con)
Dim ds As New DataSet()
daEmp.Fill(ds, "customers")

Dim tableStyle As New DataGridTableStyle()
tableStyle.MappingName = "customers"

Dim DataGridTBXColumn As DataGridTextBoxColumn = Nothing

Dim i As Integer
Dim numCols As Integer = ds.Tables("customers").Columns.Count

For i = 0 To numCols - 1
DataGridTBXColumn = New DataGridTextBoxColumn()
DataGridTBXColumn.TextBox.Enabled = False
DataGridTBXColumn.TextBox.BackColor = System.Drawing.Color.White
DataGridTBXColumn.HeaderText =
ds.Tables("customers").Columns(i).ColumnName
DataGridTBXColumn.MappingName =
ds.Tables("customers").Columns(i).ColumnName
tableStyle.GridColumnStyles.Add(DataGridTBXColumn)
Next

DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(tableStyle)

DataGrid1.DataSource = ds.Tables("customers")
End Sub
End Class
Mar 7 '07 #2
sugee
35
how does this solve my problem?
Mar 7 '07 #3
radcaesar
759 Expert 512MB
The column styles are changed to TextBox Column and their Enabled property is set to FALSE.

:)
Mar 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
3
by: Jianfeng Chen | last post by:
no problem with vb6, but what's wrong with the datagrid binding with vb.net? thanks.
1
by: Joe Lalor | last post by:
I want to disable row deletion in a Windows form datagrid. I have tried using the row_changed/row_deleted events for the datasource to reject changes for the row : this prevents the row from being...
1
by: ziad dodin | last post by:
how to disable the DELETE key in a gatagrid control without having to make the datagrid as READ-ONLY; I wander if there is a code to diable this key because it is very dangerous in master detail...
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: Geroge D. Lake | last post by:
Hi, I need to disable the resizing of a datagrid. I have tried al day and no luck. Any Ideas? Thanks. George.
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...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
2
by: Mike | last post by:
Hi, I would like to disable sorting in a winform datagrid when a column header is clicked. The following does *not* seem to disable sorting and clicking the column header still sorts the grid:...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
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...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.