|
Hi
Is there an equivalent to UML multiplicitys and Association Class in the Visual Studio Class Designer?
and how i can draw Association Class in the Visual Studio Class Designer?
thanks ....
|
|
|
|
|
Hi,
I've got a custom user control using inheritance that I'm working on that I would like to cancel the 'Click' event. Any help would be greatly appreciated.
|
|
|
|
|
From the MSDN documentation on the Control.OnClick method:
The OnClick method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Notes to Inheritors: When overriding OnClick in a derived class, be sure to call the base class's OnClick method so that registered delegates receive the event.
From reading this, I infer that if you override your inherited control's OnClick method and do not call base.OnClick, then any registerd event handlers will not receive the event notification.
The code below shows this:
using System;
using System.Windows.Forms;
namespace OnClickOverride
{
public class MainForm : Form
{
public MainForm()
{
Height = 100;
Width = 200;
Button b = new Button();
b.Text = "Normal";
b.Top = 10;
b.Left = 10;
b.Click += new EventHandler( normal_Click );
Controls.Add( b );
b = new OverriddenButton();
b.Text = "Abnormal";
b.Top = 10;
b.Left = 100;
b.Click += new EventHandler( abnormal_Click );
Controls.Add( b );
}
private void normal_Click( object sender, EventArgs e )
{
MessageBox.Show( "Clicked the normal button." );
}
private void abnormal_Click(object sender, EventArgs e)
{
MessageBox.Show( "Clicked the abnormal button." );
}
[STAThread]
public static void Main()
{
Application.Run( new MainForm() );
}
}
public class OverriddenButton : Button
{
protected override void OnClick(EventArgs e)
{
}
}
}
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanks for your reply; I'm trying to work it out in context.
|
|
|
|
|
Hi,
I'm not certain how to use this in a user control? Someone suggested I use this:
protected override void onclick(System.EventArgs e)
{
//base.onclick (e);
}
But it returned an error saying "no suitable method found to override".
I'm trying to interrupt the event in the user control and not in the parent form.
|
|
|
|
|
Two things, really.
1) Does the user control inherit from the System.Windows.Forms.Control class?
2) I'm sorry, but the formatter messed up my code. The method has a capital O and capital E so that it reads OnClick.
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace RadioButtonRocLib
{
public class RadioButtonRoc : System.Windows.Forms.RadioButton
{
private System.ComponentModel.Container components = null;
public RadioButtonRoc()
{
Code continues.........
|
|
|
|
|
This following builds but I see no effect in my test form:
protected override void OnClick(System.EventArgs e)
{
base.OnClick(e);
}
-- modified at 16:01 Monday 14th November, 2005
|
|
|
|
|
If you don't want the radio button to process the OnClick event, remove the base.OnClick(e) call from your code.
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
make it like this
protected override void OnClick(System.EventArgs e)
{
//base.OnClick(e);
}
|
|
|
|
|
Hi Josh,
I think the Code Project site has reformatted your code or else it's identical previous suggestions.
|
|
|
|
|
Hi,
I have a listview (property View is "Details"). I set the sorting property true. Is it possible that the sorting is made after the second column and not the first one (like it does now)?
Thanks!
|
|
|
|
|
Yes, it's possible. But it's not easy. You have to handle the ColumnClick event of the ListView , provide you own sorting mechanism...
But wait, actually it's easy Simply use the ListViewSortManager class from the following article:
http://www.codeproject.com/cs/miscctrl/lvsortmanager.asp[^]
I hope it helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
hi all,
I would want to allow the opening of particular system dialog from my c# application. I heave find this article written in mfc/c++, is possible to written a similar class in c# ? I have tried but my solution not allow to open a system dialog as modal.
this is my class:
using System;<br />
using System.IO;<br />
using System.Diagnostics;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace System<br />
{<br />
public class SystemDialogs<br />
{<br />
public SystemDialogs()<br />
{<br />
<br />
}<br />
<br />
public enum Dialogs<br />
{<br />
SD_FORMAT = 1,<br />
SD_INTERNET_OPTIONS = 2,<br />
SD_ADD_REMOVE_PROGRAMS = 3,<br />
SD_DATE_TIME = 4,<br />
SD_DISPLAY = 5,<br />
SD_MODEM = 6,<br />
SD_MULTIMEDIA = 7,<br />
SD_MOUSE = 8,<br />
SD_NETWORK = 9,<br />
SD_PASSWORD = 10,<br />
SD_SYSTEM = 11,<br />
SD_REGIONAL_SETTINGS = 12,<br />
SD_SOUNDS = 13,<br />
SD_GAME_CONTROLLERS = 14,<br />
SD_KEYBOARD = 15,<br />
SD_DEVICE_MANAGER = 16,<br />
}<br />
<br />
public static void ShowDialog(SystemDialogs.Dialogs Dialog)<br />
{<br />
string[] Args = new string[16]<br />
{<br />
"Shell32.dll SHFormatDrive",<br />
"Shell32.dll Control_RunDLLA inetcpl.cpl 0",<br />
"Shell32.dll Control_RunDLLA appwiz.cpl",<br />
"Shell32.dll Control_RunDLLA timedate.cpl",<br />
"Shell32.dll Control_RunDLLA desk.cpl",<br />
"Shell32.dll Control_RunDLLA modem.cpl",<br />
"Shell32.dll Control_RunDLLA mmsys.cpl 0",<br />
"Shell32.dll Control_RunDLLA main.cpl @0",<br />
"Shell32.dll Control_RunDLLA netcpl.cpl",<br />
"Shell32.dll Control_RunDLLA password.cpl",<br />
"Shell32.dll Control_RunDLLA sysdm.cpl 0",<br />
"Shell32.dll Control_RunDLLA intl.cpl 0",<br />
"Shell32.dll Control_RunDLLA mmsys.cpl @1",<br />
"Shell32.dll Control_RunDLLA joy.cpl",<br />
"Shell32.dll Control_RunDLLA main.cpl @1",<br />
"DevMgr.dll DeviceManager_ExecuteA"<br />
};<br />
<br />
int i = (int) Dialog - 1;<br />
Process p = new Process();<br />
p.StartInfo.FileName = "Rundll32.exe";<br />
p.StartInfo.Arguments = Args[i];<br />
p.Start();<br />
}<br />
}<br />
}
In settings form of my application i call this method:
using System;<br />
-----------<br />
----------<br />
SystemDialogs.ShowDialog(SystemDialogs.Dialogs.SD_INTERNET_OPTIONS);
...for showing the internet options dialog as no modal ...
suggestions ?
tnx to all and excuse me for eventual grammar's errors .... i'm italian
|
|
|
|
|
Is there a function that will automatically turn a relative path into an abosolute one? I could use Application.ExecutablePath and iterate up a level for each ..\ in the relative one if not but I'd just as soon not reinvent the wheel.
|
|
|
|
|
Have you looked at the Path.GetFullPath( string ) method?
From the documentataion:
Returns the absolute path for the specified path string.
For example, if I write a console application that contains the following statement as the sole entry in the Main function:
Console.WriteLine( System.IO.Path.GetFullPath( "..\\.\\moo.txt" ) );
and run it from the Command window, I'd get:
c:\dir1\dir2\dir3\dir4> RunGetFullPathTest.exe
c:\dir1\dir2\moo.txt
c:\dir1\dir2\dir3\dir4>
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Curtis S. wrote: Have you looked at the Path.GetFullPath( string ) method?
Thank you, that's exactly what I was looking for.
|
|
|
|
|
'T was my pleasure. I'm glad I could help.
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi!
I would like to make a control that can contain other controls. I know how to accomplish this by inheriting the Panel. Next problem is how to reserve parts of the control for headers etc., ie restrict the ClientRectangle to a part of the control. Is this possible.
BR
Christian
|
|
|
|
|
There may be other ways to do this.
What if you change the location of the child control in the ControlAdded event if the child control is drawn in the Header area.
|
|
|
|
|
Hi all,
I'm writing an assembly which processes incoming messages from a tcp socket and fires an event if a relevant message is received. I understand the need to fire the message on the appropriate thread, but was hoping that instead of the consumer of my client having to use begininvoke, i could somehow pass in the thread I want the event to fire on as a parameter and have the control handle the event without 'knowing' which thread it came from.
Is this at all possible, or have i missed what is going on here.
Thanks for any help anyone gan give,
Russell
|
|
|
|
|
|
arachnoid wrote: understand the need to fire the message on the appropriate thread
Does that come from the need of modifying the UI on the thread it was created? You usually only have one UI thread so writing formname.BegingInvoke isn't too complicated.
If you are talking about worker threads that only process the events without touching the UI, I usually just queue them in a work queue. I wrote a class that create a delegate that do it transparently from another one. I really should write an article on that.
You can mix both technique to have both UI and direct delegate on the same event, just make a class like this:
class UIDelegate<br />
{<br />
private ISynchronizeInvoke mSync;<br />
private Delegate mDelegate;<br />
<br />
public static Delegate Create( ISynchronizeInvoke sync, Delegate d )<br />
{<br />
UIDelegate newd = new UIDelegate( sync, d );<br />
return Delegate.CreateDelegate( d.GetType(), newd , "Handler" );<br />
}<br />
<br />
private UIDelegate( ISynchronizeInvoke sync, Delegate d )<br />
{<br />
mSync = sync;<br />
mDelegate = d;<br />
}<br />
<br />
private void Handler( object sender, EventArgs arg )<br />
{<br />
if ( mSync.InvokeRequired )<br />
{<br />
mSync.BeginInvoke( mDelegate, new object[]{ arg } );<br />
}<br />
else<br />
{<br />
mDelegate.DynamicInvoke( new object[]{ arg } );<br />
}<br />
}<br />
}<br />
<br />
myObjectOnAnotherThread.AnEvent += (EventHandler)UIDelegate.Create( theForm, new EventHandler(TheFunction) );
I am trying to get the indentation right but it seems I cant figure it out and I need to go home.
I did not compile it, just wrote what I remember from the class I have at home.
That will hide the ugly forwarding into the UIDelegate class this was other classes do not need to be aware of UI things to do their job correctly.
I use the same principle to queue the request and execute it later on my worker threads.
|
|
|
|
|
I need to implement YesToAll,NoToAll feature with messagebox. Say I have several images, when user selects ClearAll...I want to show Prompt with Yes,No,YesToall,NoToAll..Yes would delete current image and prompt with next image, No would skip current image and prompt with next image
How can it communicate with business logic? I have to pop up messagebox each time if user selects yes or no for image
Thanks for anticipation.
Regards,
MaulikCE
|
|
|
|
|
You need to a create a form with that functionality. Messagebox doesn't provide any way to do it.
|
|
|
|