PC Review


Reply
Thread Tools Rate Thread

Datagrid - restrict the user input anything for some columns.

 
 
Agnes
Guest
Posts: n/a
 
      27th Nov 2004
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 ?

--
..


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hhcmxpZQ==?=
Guest
Posts: n/a
 
      27th Nov 2004
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 ?
>
> --
> ..
>
>
>

 
Reply With Quote
 
Agnes
Guest
Posts: n/a
 
      28th Nov 2004
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" <(E-Mail Removed)> ¦b¶l¥ó
news:CF309091-4342-4F17-8655-(E-Mail Removed) ¤¤¼¶¼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 ?
> >
> > --
> > ..
> >
> >
> >



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      28th Nov 2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data validation won't restrict user input - please help A. Young Microsoft Excel Misc 1 7th Feb 2010 01:50 AM
How to restrict user to input only one of multiple cells James Microsoft Excel Worksheet Functions 1 28th Aug 2008 04:23 PM
restrict user input to 2 lines Tom Microsoft Access Form Coding 7 14th Aug 2006 03:32 PM
Restrict User Input Sala Microsoft Excel Programming 7 4th May 2004 07:39 PM
Restrict clicking child datagrid columns Kenneth Bohman Microsoft Dot NET Framework Forms 2 23rd Sep 2003 10:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:06 AM.