473,320 Members | 2,073 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 - restrict the user input anything for some columns.

In textbox, I know I can set e.handled = false in keypressevent , So I can
restrict the user to input some invalid character or disallow the user to
input any thing
Now, in datagrid, there are 3 columns one is account code, 2nd is debit, 3rd
is credit
for some account code, (e.g bank) I want to allow the user to input both
debit and credit column/
BUT for some account code( E.g salary) I want to disallow the user type
anything in 'credit' column.

I try edit some code in ProcessCmdKey() , and d/l the some sample code
from http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
But I still fail to restrict the user ,
Does anyone got some idea ?

--
..
Nov 21 '05 #1
3 2468
You could use try this. I did not test it. If you try it, please post
whether it works.

Dim tc() As DataGridTextBoxColumn = {New DataGridTextBoxColumn(), _
New DataGridTextBoxColumn()}
'Set properties of tablecolumns
tc(0).MappingName = "Col1"
tc(0).HeaderText = "Col 1"
tc(0).ReadOnly = True
tc(1).MappingName = "Col2"
'...
Dim ts As New DataGridTableStyle()
ts.GridColumnStyles.AddRange(tc)
Me.DataGrid1.TableStyles.Add(ts)
me.DataGrid1.DataSource = 'datatable or dataview. Fields are mapped
by mapping names. Each mapping name must match a field.

www.charlesfarriersoftware.com

"Agnes" wrote:
In textbox, I know I can set e.handled = false in keypressevent , So I can
restrict the user to input some invalid character or disallow the user to
input any thing
Now, in datagrid, there are 3 columns one is account code, 2nd is debit, 3rd
is credit
for some account code, (e.g bank) I want to allow the user to input both
debit and credit column/
BUT for some account code( E.g salary) I want to disallow the user type
anything in 'credit' column.

I try edit some code in ProcessCmdKey() , and d/l the some sample code
from http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
But I still fail to restrict the user ,
Does anyone got some idea ?

--
..

Nov 21 '05 #2
I know I can use DataGridTableStyle() to set my datagrid but the property
"Read Only" will only make that specified columns is read only. However , my
problem is "case dependent" , If column (1) is "ABC", column2 or column3
can be input.
if column(2) is "XYZ" , column3 can be inputed only. Each row got different
behaviour.
Anyway, I try to seek another solution..
Thanks for your reply
--
..
"Charlie" <Ch*****@discussions.microsoft.com> ¦b¶l¥ó
news:CF**********************************@microsof t.com ¤¤¼¶¼g...
You could use try this. I did not test it. If you try it, please post
whether it works.

Dim tc() As DataGridTextBoxColumn = {New DataGridTextBoxColumn(), _
New DataGridTextBoxColumn()}
'Set properties of tablecolumns
tc(0).MappingName = "Col1"
tc(0).HeaderText = "Col 1"
tc(0).ReadOnly = True
tc(1).MappingName = "Col2"
'...
Dim ts As New DataGridTableStyle()
ts.GridColumnStyles.AddRange(tc)
Me.DataGrid1.TableStyles.Add(ts)
me.DataGrid1.DataSource = 'datatable or dataview. Fields are mapped by mapping names. Each mapping name must match a field.

www.charlesfarriersoftware.com

"Agnes" wrote:
In textbox, I know I can set e.handled = false in keypressevent , So I can restrict the user to input some invalid character or disallow the user to input any thing
Now, in datagrid, there are 3 columns one is account code, 2nd is debit, 3rd is credit
for some account code, (e.g bank) I want to allow the user to input both
debit and credit column/
BUT for some account code( E.g salary) I want to disallow the user type
anything in 'credit' column.

I try edit some code in ProcessCmdKey() , and d/l the some sample code
from http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
But I still fail to restrict the user ,
Does anyone got some idea ?

--
..

Nov 21 '05 #3
Agnes,
I know I can use DataGridTableStyle() to set my datagrid but the property
"Read Only" will only make that specified columns is read only. However ,
my
problem is "case dependent" , If column (1) is "ABC", column2 or column3
can be input.
if column(2) is "XYZ" , column3 can be inputed only. Each row got
different
behaviour.
Anyway, I try to seek another solution..


I think that that will be in this case the best. You need to control the
input of the datagrid now completly and when a account code column is
changed, you are direct in trouble again when the row is already filled,
(you should have to keep the user on the row until the row is completly
correct).

In this case I think that I would try a texboxes approach above the grid
synchronized using the currencymanager.

Just my thougth,

Cor

Nov 21 '05 #4

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

Similar topics

0
by: JR | last post by:
Hello, Does anyone know how you can prevent a row full of 'null' values from being added to the datagrid when a user hits the delete key, deleting the word (null) which represents the default...
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...
5
by: DotNetGruven | last post by:
Anyone have any pointers on how to set the Value and Selected attributes in a ListItem in a RadioButtonList that is in a DataGrid? Here's what I have ------DataGrid------ -- BoundColumn 0 --...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
2
by: Luis Esteban Valencia Muñoz | last post by:
I have a datagrid that displays editable text fields (2 different price fields) and a checkbox in every row. It has a "SaveChanges" button at the bottom, which, when pressed, looks at every...
0
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
9
by: BK | last post by:
In VB.Net (1.1 framework), I have a datagrid that displays records from a SQL table. Only some of the columns are editable. When the user changes data in 2 and only 2 of the columns, I want to...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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
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...

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.