|
Hello Luc,
Luc Pattyn wrote: I consider it bad practice to change the behavior of a standard Control
I don't agree in this point, as I often manipulat standard Controls for my needs.
As "overriding" gives me the chance to change the behavior of controls in the way my "customer" is used to it from machines my company delivered years ago.
And I think the point is, as some people (including me) are not doing WEB Applications or standard Windows Application for PC's, your statement doesn't fit for all.
All the best,
Martin
|
|
|
|
|
Hi Luc,
you are right, sorry, I override the onclick event and created an own event called checkBeforeChange like this
protected override void OnClick(EventArgs e) <br />
{ <br />
if(this.BeforeStateChange != null)<br />
{<br />
this.BeforeStateChange(this, ref cancelStateChg);<br />
}<br />
if(this.cancelStateChg)<br />
{ <br />
this.Checked = !this.Checked;<br />
} <br />
base.OnClick (e);<br />
}<br />
this code is working on a checkbox, but not on a radiobutton.
I would use enable=true/false but the bad is the color change to gray. If I could prevent the colorchange, everything would be fine.
Frank
-- modified at 6:37 Thursday 12th July, 2007
|
|
|
|
|
I understand that, but the basic point is a Control that is disabled MUST
look different; if it did not, the user would manipulate it unknowingly,
and then complain it does not work as expected.
|
|
|
|
|
Hi luc
a disabled control should look different, but in a way I can decide of, and not in the way MS do.
tnx
|
|
|
|
|
Standards are fantastic. Everyone should have one.
|
|
|
|
|
A simple solution is to intercept checkchanged, and set the button back to checked if it is not checked.
Not the most elegant though
|
|
|
|
|
Hello,
fracalifa wrote per e-mail: Hi Martin,
tnx, that works, but how can I prevent the statechange of the radiobutton ? Is there a cancel option which I can use for?
Tnx Frank [confused]
I haven't even found "statechange", is it .NET>1.1?
P.S.: please respond in the forum, cause I'm not answering per e-mail!
All the best,
Martin
|
|
|
|
|
Hi Martin,
other than a checkbox a radiobutton is a group of controls. With the checkbox I can do suppressing the toggle of the state, with the radiobutton(s) I can do not.My wish is to prevent the change of state from uncheched to checked when clicking on it, that's all (without enable = false).
tnx Frank
|
|
|
|
|
But haven't you allready told the solution with overriding the OnClick.
I tested it with an inherited (from RadioButton) control.
private bool _disable = false;
public bool Disable
{
get
{
return _disable;
}
set
{
if(value!=_disable)
{
_disable = value;
}
}
}
protected override void OnClick(EventArgs e)
{
if(!Disable)
base.OnClick (e);
}
Works well for me.
All the best,
Martin
|
|
|
|
|
Yes, that's it,
my fault was the calling of the base class even when it is disabled.
tnx
|
|
|
|
|
Glad I could help!
You are wellcome!
All the best,
Martin
|
|
|
|
|
Hello there,
I have been asked to create a design surface where you can drag and drop controls onto this surface and it will automatically generate the XAML code , now the problem is i have never done this before, so if there is anyone who can help me with this it would be greatly appreciated.
thanks in advance
|
|
|
|
|
|
thanks for the reply,
im actually trying to create a custom IDE like VS that i can drag and drop controls onto a surface and the XAML code for those controls will be generated automatically,
|
|
|
|
|
Well yes, that's what Expression Blend does. It'll probably be cheaper to buy it than putting in vast amounts of time and trouble to create something similar.
Standards are great! Everybody should have one!
|
|
|
|
|
Expression Blend would work but we are looking to create a custom one that we can develop and deploy so that anyone can create a custom application simply by dragging controls onto a design surface
|
|
|
|
|
Hi,
I've created a timer object with these statements
private Timer stepTimer = new Timer();
stepTimer.Interval = 1000;
stepTimer.Tick += new EventHandler(stepTimer_Tick);
these statements are in my constructor.
when I call stepTimer.Start(); in the constructor it comes to the stepTimer_Tick method.
However, when I do that somewhere else (for example I am trying to call in another callback function)
it does not enter the function stepTimer_Tick.
I've taken the statement (stepTimer.Start(); ) to different locations but it is still the same. How can I solve that.
Thanks...
aysan ethem narman
|
|
|
|
|
Hello,
As you are using the Forms.Timer which is running in the UI thread, you have to be carefull when accessing it from an other thread.
In this case you have to invoke the method which calls the Timer like this.
private delegate void EnableTimerDelegate();
private void EnableTimer()
{
if(InvokeRequired)
{
Invoke(new EnableTimerDelegate(EnableTimer), new object[] {});
return;
}
if(!stepTimer.Enabled)
{
stepTimer.Enabled = true;
}
}
Invoke and InvokeRequired are members of Control.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
Thank you very much it works.
Interesting thing is I've met cross thread operation many times before, I've caught them with try catch blocks and solved with invoke method as you did. However, this time it did not fire any exception although it is again in a try-catch block. So I did not doubt about this problem.
Again thank you...
aysan ethem narman
|
|
|
|
|
Hello,
alashara wrote: Thank you very much it works.
Glad I could help!
You are wellcome!
-- modified at 5:53 Thursday 12th July, 2007
I assume that you now don't work with this dirty try/catch blocks and use the InvokeRequired instead, at least I would suggest it!
P.S.: It's allways nice to read a "Thank you", like you did! Got my '5' for that!
All the best,
Martin
|
|
|
|
|
Hi,
to which try-catch block should an InvalidOperationException (the one that
fires on cross-thread sins) report when it occurs in a callback method
(i.e. one that does not include its own try-catch) ?
It just gets swallowed. There are a couple of situations where an Exception
seems to disappear, you wont notice unless you look very carefully...
UnhandledException got added in .NET 2.0 to improve on the situation.
|
|
|
|
|
Hi all,
Does anyone know how to change the computers short date format that is listed in the control panel (Regional and Language Options).
If anyone is thinking go into the control panel and change it... no... -.-;
I need to do it programmically!.
Cheers,
Mark
|
|
|
|
|
Haven't used that befor, but "kernel32.dll" provides a lot of usefull methods in this topic.
Like:
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct SystemTime
{
public short sYear;
public short sMonth;
public short sDayOfWeek;
public short sDay;
public short sHour;
public short sMinute;
public short sSecond;
public short sMilliSeconds;
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern bool SetLocalTime(ref SystemTime time);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern bool GetLocalTime(ref SystemTime time);
Or:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TimeZoneInformation
{
public int bias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string standardName;
SystemTime standardDate;
public int standardBias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string daylightName;
SystemTime daylightDate;
public int daylightBias;
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern bool SetTimeZoneInformation([In] ref TimeZoneInformation lpTimeZoneInformation);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern int GetTimeZoneInformation(out TimeZoneInformation lpTimeZoneInformation);
Maybe you are luky with kernel32?
All the best,
Martin
|
|
|
|
|
how we can access "protected internal" class?
vamsi
|
|
|
|
|
Sounds that this question is asked in the Interview?
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|