Click here to Skip to main content
15,910,877 members
Home / Discussions / C#
   

C#

 
QuestionCenter Text on Custom Button Pin
PHDENG8122-May-07 7:17
PHDENG8122-May-07 7:17 
AnswerRe: Center Text on Custom Button Pin
Manoj Kumar Rai22-May-07 8:02
professionalManoj Kumar Rai22-May-07 8:02 
GeneralRe: Center Text on Custom Button Pin
PHDENG8122-May-07 8:29
PHDENG8122-May-07 8:29 
AnswerRe: Center Text on Custom Button Pin
Ian Shlasko22-May-07 10:34
Ian Shlasko22-May-07 10:34 
GeneralRe: Center Text on Custom Button Pin
PHDENG8123-May-07 0:45
PHDENG8123-May-07 0:45 
GeneralRe: Center Text on Custom Button Pin
Ian Shlasko24-May-07 3:40
Ian Shlasko24-May-07 3:40 
GeneralRe: Center Text on Custom Button Pin
PHDENG8124-May-07 4:38
PHDENG8124-May-07 4:38 
QuestionDisabling controls without changing appearance Pin
Ian Shlasko22-May-07 6:13
Ian Shlasko22-May-07 6:13 
I'm writing a rather large data access application (CLR 2.0, rich-client), and I've started adding some security routines. Simple flags to prevent certain users from editing certain items.

Basically, I have a number of record editing dialogs (Well, I have one so far, but there will be many), and I'm trying to find a way to make them double as read-only viewers for users who aren't allowed to make changes.

The idea is to prevent the user from interacting with any controls that are "locked" without damaging the appearance.

* I don't want to subclass the windows forms controls (I'm using aspects to add custom behavior via event hooking when needed) as the program uses a LOT of them, and I don't want to slow down GUI updates and layout logic with extra layers of inheritance, especially when only a fraction of the controls will use this particular feature.

* I don't want to just set the Enabled property, as this grays out the control, making it difficult to read and therefore useless as a viewer. Textboxes have their ReadOnly property, but this doesn't help for dropdowns, checkboxes, etc.

* Data integrity is not an issue here, as the changes are all funneled through a secure update routine. This is exclusively a display issue. I don't want the user to be able to change control values if those changes can't be saved anyway.

I can hook the keydown events to kill any keyboard actions on them, and set a dummy context menu to prevent right-click copy/pasting, so textboxes are easily handled. It's the other controls (Comboboxes, checkboxes, radiobuttons) that are the real issue.

Since I can restrict any keyboard entry, an ideal solution would be a way to just intercept any mouse activity before it reaches the controls. On a simpler scale, I could hover a transparent form to actually shield them, but that would be horribly inefficient in this case.

I've tried hooking the GotFocus and automatically moving the focus to another control, but this isn't sufficient, since the initial mouse click goes through before the focus is moved, and that's enough to click a button or hit the dropdown button on a combobox. Looks amateurish if the dropdown triggers, then kicks you out.

Worst case, I'll just make separate editors and viewers, but I'm trying to avoid this if possible. This app will see a lot of maintenance, by me and any future teammates, and I want that to be as painless as possible.

Any ideas?
AnswerRe: Disabling controls without changing appearance Pin
Dave Herren22-May-07 6:33
Dave Herren22-May-07 6:33 
GeneralRe: Disabling controls without changing appearance Pin
Ian Shlasko22-May-07 7:42
Ian Shlasko22-May-07 7:42 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Ian Shlasko22-May-07 10:05
Ian Shlasko22-May-07 10:05 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Martin#22-May-07 21:43
Martin#22-May-07 21:43 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Ian Shlasko23-May-07 6:13
Ian Shlasko23-May-07 6:13 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Martin#23-May-07 7:04
Martin#23-May-07 7:04 
AnswerRe: Disabling controls without changing appearance Pin
Dave Herren22-May-07 6:38
Dave Herren22-May-07 6:38 
AnswerRe: Disabling controls without changing appearance Pin
Dan Neely22-May-07 7:20
Dan Neely22-May-07 7:20 
Questionrun .exe from command prompt in c#...help please Pin
lavy288322-May-07 5:22
lavy288322-May-07 5:22 
AnswerRe: run .exe from command prompt in c#...help please Pin
Bekjong22-May-07 5:44
Bekjong22-May-07 5:44 
AnswerRe: run .exe from command prompt in c#...help please Pin
Mike DiRenzo22-May-07 9:16
Mike DiRenzo22-May-07 9:16 
AnswerRe: run .exe from command prompt in c#...help please Pin
Nouman Bhatti23-May-07 0:49
Nouman Bhatti23-May-07 0:49 
AnswerRe: run .exe from command prompt in c#...help please Pin
Hamid_RT23-May-07 2:18
Hamid_RT23-May-07 2:18 
QuestionHow to acess Website from windows Forms Pin
Rahul8322-May-07 4:57
Rahul8322-May-07 4:57 
AnswerRe: How to acess Website from windows Forms [modified*2] Pin
Tarakeshwar Reddy22-May-07 5:02
professionalTarakeshwar Reddy22-May-07 5:02 
GeneralRe: How to acess Website from windows Forms Pin
Rahul8322-May-07 5:07
Rahul8322-May-07 5:07 
GeneralRe: How to acess Website from windows Forms Pin
Manoj Kumar Rai22-May-07 5:46
professionalManoj Kumar Rai22-May-07 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.