|
Did you check the EventArgs? Sometimes they stuff things in like the OriginalSource, etc. Besides, how are you throwing up the context menu?
|
|
|
|
|
Yes I looked in the eventargs didn't see anything in there either.
And I'm throwing up the context menu via right click. (Not sure if that is what your asking)
But I solved the problem by using the Tag property as suggested earlier.
|
|
|
|
|
Try this:
ToolStripMenuItem itm = sender as ToolStripMenuItem;
if (itm != null)
{
ContextMenuStrip cm = (ContextMenuStrip)itm.Owner;
MessageBox.Show(cm.SourceControl.ToString());
}
Obviously I'm only showing the control in a MessageBox . You can do whatever you need to with it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
hi
i made message-box -> a form that has label for message and label for title
and OK button (do nothing).
i can rise this message from any form in my program.
i need message-box that has yes button and no button, and to know
if it pressed yes or no
how to do it ?
can i get any sample code for this ?
|
|
|
|
|
|
A dialog (i.e. a Form shown with ShowDialog) will close and return a DialogResult once one of its buttons is clicked, provided that button has its DialogResult set to something other than DialogResult.None, so use Visual Designer or your own code to assign dialog results to the buttons that should close the dialog, and capture the ShowDialog()'s return value.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
hi guies
i want program to draw and send this drawing to any one
in chatting program by c# with gdi+ technique
|
|
|
|
|
That's nice.
Please read this[^]
If you have a problem and need help then ask, don't just ask for code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
|
but I don't have time to create new one
I want read in exist one to get idea
and develope my project
|
|
|
|
|
Well, considering you've been asking about this for months now and haven't gotten anywhere because you haven't done any of the work required up till now, the chances of you getting a project like this completed on time are now zero.
Now, IF you con some poor schmuck into giving you said source code, you have no chance of understanding it so when YOUR implementation breaks, you have no hope of supporting/fixing it in a timely fashion.
|
|
|
|
|
good luck
I cannot remember: What did I before google?
|
|
|
|
|
So, basically you are asking us to help you cheat. Them, if you pass your course, I assume you will want to get a job where you will be expected to write code - will we be expected to help you cheat then? Will you give us your salary?
I'm sorry, but I have absolutely no sympathy for you. You have wasted your time, and you are going to fail. I hear that Burger King are hiring.
|
|
|
|
|
Burger King still expects its employees to know how to follow instructions.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
You need to give your email address so we know where to send the source code to.
|
|
|
|
|
my email memo_aljabri11@hotmail.com
|
|
|
|
|
do
{
AskForCode();
}while(user == ID10T)
I sense an infinate loop
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
do
{
ASkForCode();
}while(user==Busy)
|
|
|
|
|
public const string Busy = "Still no reason to not try something yourself";
FTFY
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi all,
As a part of my project I have an abstract class that looks like this:
abstract class TabPageTemplate : TabPage
{
public abstract void Process();
public abstract void Cancel();
public abstract bool LoseFocus();
public abstract void Populate(int identifier);
public abstract event EventHandler PageClosed;
}
I also have separate classes defined, all of which implement the above abstract class. On another Form (that contains a TabControl ) I can then add any of these TabPages and know that each one will have implemented the four methods and one event handler so I can call any of them.
It works great, but there is one major inconvenience. I have to design the layout of all of those TabPages in code, I cannot use the VS Designer. The reason for this is that the Designer can't create an instance of whatever TabPage I'm busy designing (because the base class from which the TabPage inherits is abstract ). This is the error message that the Designer gives me:
The designer must create an instance of type 'MyProject.TabPageTemplate' but it cannot because the type is declared as abstract.
Would anyone have some advice for me here? At first this wasn't a problem but these TabPages are getting quite complex now and doing all of the control layout in code is getting very tedious.
|
|
|
|
|
I see two ways to solve the problem:
1. drop the abstract keyword, which obviously means you're also dropping the "must implement" protection.
2. or: use Visual Designer to design either a specialized Pamel, or a UserControl, and use code to put one of those on each of your tab pages.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry Sir,
But I am trying for 20 minutes to design a specialised Pamel but Visual Studio does not recognise this kind of control. I am using Visual Studio 2010. Please help! it's urgentz
|
|
|
|
|
public class Pamel : Panel {
}
works for me every time.
PS: Feel free to choose another class name.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks Luc, number 2 is what I have been doing so far but it is more tiresome than one might think - which is why I decided I need to make a plan and find a better way of doing this.
I can't just drop the abstract keyword because the section of code that calls the overridden methods doesn't know which TabPage it is accessing. It does something like this:
(TabPage_First as TabPageTemplate).Process()
which means that TabPageTemplate must have a Process() method and it must be overridden by TabPage_First (and all the other TabPages that implement TabPageTemplate ).
I can however have TabPage_First inherit from TabPage as opposed to TabPageTemplate , then open it in Designer and do what I want to do, after which I change the inheritance back to TabPageTemplate again. It's a little bit of hassle but nothing as bad as the way I used to do it.
HOWEVER, once I did that I made another unpleasant discovery. You can't use Designer to design the visual layout of controls on a TabPage if the TabPage isn't inside a TabControl . All it shows is a list of all the controls on the TabPage but not positioned on the screen as their properties dictate. You can change their properties (size, location, etc.) but it doesn't show on the TabPage in Designer, you only see it once you compile and run the application.
So here's what I ended up doing, just in case anyone else is interested;
In stead of the TabPageTemplate as described above I defined a UserControlTemplate as follows:
public abstract partial class UserControlTemplate : UserControl
{
public abstract void Process();
public abstract void Cancel();
public abstract bool LoseFocus();
public abstract void Populate(int identifier);
public abstract event EventHandler PageClosed;
}
I then design various UserControls , all of which implement the above abstract UserControlTemplate . At runtime I then create a new empty TabPage , add this UserControl (let's say I call it UserControl_First ) to the TabPage , set its Dock value to Fill and then add that TabPage to the TabControl .
I still have to change the inheritance of the UserControl_First from UserControlTemplate to UserControl in order to edit it in Designer and back to UserControlTemplate before compiling but other than that little hassle it works like a charm.
|
|
|
|