Click here to Skip to main content
15,890,947 members
Home / Discussions / C#
   

C#

 
AnswerRe: Identifying file is in use Pin
Giorgi Dalakishvili21-Aug-07 22:03
mentorGiorgi Dalakishvili21-Aug-07 22:03 
GeneralRe: Identifying file is in use Pin
Martin#21-Aug-07 22:24
Martin#21-Aug-07 22:24 
GeneralRe: Identifying file is in use Pin
Giorgi Dalakishvili21-Aug-07 22:26
mentorGiorgi Dalakishvili21-Aug-07 22:26 
GeneralRe: Identifying file is in use Pin
Martin#21-Aug-07 22:33
Martin#21-Aug-07 22:33 
GeneralRe: Identifying file is in use Pin
N a v a n e e t h21-Aug-07 22:48
N a v a n e e t h21-Aug-07 22:48 
GeneralRe: Identifying file is in use Pin
N a v a n e e t h21-Aug-07 22:50
N a v a n e e t h21-Aug-07 22:50 
Question"handling" an event on controls Pin
cignox121-Aug-07 20:58
cignox121-Aug-07 20:58 
AnswerRe: "handling" an event on controls Pin
Martin#21-Aug-07 22:09
Martin#21-Aug-07 22:09 
Hello,

Most controls react on the MouseDown event!
So it would be an option to inherit your special control from the control you would liek to modify.
Then you just have to add some properties which tell you how to react.
Your inherited control can than override the method which fires the MouseDown event, and block the call of the base method.
This will, of course lead to an unexpected reaction (nothing happens) for the user of your control.
Because if you do not change the colors or do some other notivication, he would expect the MouseDown to fir and for example the CheckBox changing their Checked state.

Here is an example for the CheckBox, where I just added a property called "ReadOnly" and overrided "OnMouseDown":
using System;
using System.ComponentModel;
 
namespace YourNamespace
{
	public class ReadOnlyCheckBox : System.Windows.Forms.CheckBox
	{
		/// <summary>
		/// constructor (empty)
		/// </summary>
		public ReadOnlyCheckBox()
		{
		}
 
		private bool _readonly = true;
 
		/// <summary>
		/// This property enables/disables the functonality of the control
		/// </summary>
		[Category("ReadOnlySpecials")]
		[Description("This property enables/disables the functonality of the control")]
		[DefaultValue(true)]
		public bool ReadOnly
		{
			get
			{
				return _readonly;
			}
			set
			{
				if(value!=_readonly)
				{
					_readonly = value;
				}
			}
		}
 
		protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
		{
			//base method is only called,if ReadOnly is "false"
			if(!ReadOnly)
				base.OnMouseDown (e);
		}
	}
}


Hope it helps!

All the best,

Martin

GeneralRe: "handling" an event on controls Pin
cignox122-Aug-07 0:22
cignox122-Aug-07 0:22 
GeneralRe: "handling" an event on controls Pin
Martin#22-Aug-07 1:16
Martin#22-Aug-07 1:16 
QuestionSoftware Licening.. Pin
Rahul.RK21-Aug-07 20:40
Rahul.RK21-Aug-07 20:40 
AnswerRe: Software Licening.. Pin
Nouman Bhatti21-Aug-07 21:00
Nouman Bhatti21-Aug-07 21:00 
AnswerRe: Software Licening.. Pin
Mark Churchill21-Aug-07 21:18
Mark Churchill21-Aug-07 21:18 
QuestionDeleting a file being loaded in a picturebox Pin
aravinda77721-Aug-07 20:17
aravinda77721-Aug-07 20:17 
AnswerRe: Deleting a file being loaded in a picturebox Pin
Michael Sync21-Aug-07 20:39
Michael Sync21-Aug-07 20:39 
AnswerRe: Deleting a file being loaded in a picturebox Pin
Hessam Jalali21-Aug-07 20:41
Hessam Jalali21-Aug-07 20:41 
AnswerRe: Deleting a file being loaded in a picturebox Pin
Luc Pattyn22-Aug-07 1:01
sitebuilderLuc Pattyn22-Aug-07 1:01 
QuestionIdentifying the type of file Pin
aravinda77721-Aug-07 19:57
aravinda77721-Aug-07 19:57 
AnswerRe: Identifying the type of file Pin
Christian Graus21-Aug-07 20:01
protectorChristian Graus21-Aug-07 20:01 
GeneralRe: Identifying the type of file Pin
Michael Sync21-Aug-07 20:19
Michael Sync21-Aug-07 20:19 
GeneralRe: Identifying the type of file Pin
aravinda77721-Aug-07 20:32
aravinda77721-Aug-07 20:32 
GeneralRe: Identifying the type of file Pin
Christian Graus21-Aug-07 20:45
protectorChristian Graus21-Aug-07 20:45 
GeneralRe: Identifying the type of file Pin
Michael Sync21-Aug-07 21:59
Michael Sync21-Aug-07 21:59 
GeneralRe: Identifying the type of file Pin
Christian Graus22-Aug-07 0:10
protectorChristian Graus22-Aug-07 0:10 
AnswerRe: Identifying the type of file Pin
Michael Sync21-Aug-07 20:03
Michael Sync21-Aug-07 20:03 

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.