|
I seem to have left my brains in the other pants...
ShowDialog(IWin32Owner) will do the trick.
|
|
|
|
|
Hello,
i have a treeView component where a ContextMenuStrip is already assigned to it (ex. contextP)
now, i want to drag a node from one place to another in the treeView.
when i do so, i call the DragDrop event which has all my function's according to my needs.
in this event, i would like to call a different ContextMenuStrip named contextD.
i thought of using
<br />
.<br />
.<br />
.<br />
contextD.Show(Point pt);<br />
.<br />
.<br />
.<br />
<br />
private void contextD_Opening(object sender, CancelEventArgs e)<br />
{<br />
ToolStripMenuItem itemMove = (ToolStripMenuItem)contextDrag.Items["ctextMoveItem"];<br />
ToolStripMenuItem itemCopy = (ToolStripMenuItem)contextDrag.Items["ctextCopyItem"];<br />
ToolStripMenuItem itemCancel = (ToolStripMenuItem)contextDrag.Items["ctextCancelItem"];<br />
}<br />
but when the opening event has finished, the main code continues, and the contextD is still shown, regardless to my selection.
how can i make the contextD to stay on, depending on my selection in the menu to continue my flow (do event's etc.) ?
then of course, how to close it when im finished with it ?
thanks
Eyal
|
|
|
|
|
Hi Eyal,
I have a lot of experience working with TreeViews. Reading your description I can't really figure out what the relationship of the ContextMenuStrip and moving/copying/cancelling drag is in relationship to what you are doing with nodes.
Are you implying you want to put up a context menu strip during a drag operation : then let the user select move/copy/cancel from the context menu ?
If this is correct, would you want to put this context menu up at the moment the drag started (just after the call to 'DoDragDrop) ... or maybe when the drop target has been selected and DragDrop is being executed ?
Please describe further what your goal is here.
Using key combinations to determine whether a Drag Move or Drag Copy is being done is a fairly standard practice (usually detected in the source's ItemDrag event).
And, of course, you have the QueryContinueDrag event to use to allow cancelling in the DragSource's code in response to mouse or key events : [^]
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hello Bill,
thanks for your replay.
to be more accurate what i intend to do is after the drop target has been selected, then put up a context menu strip with the relevant options.
when the user selects copy for example, invoke the copy event which copies the source to the target..
and if the user selects cancel, do nothing
the event's are something i already have in my program, the only thing missing is this context menu strip option the will activate them properly.
have i made my self more clear ?
thanks a lot
Eyal
|
|
|
|
|
Hi Eyalle,
I think there is a "structural problem" here, but I have to disclaimer what I'll say by letting you know I'm working with a 3rd. party WinForms tree control whose behavior may be different than the standard WinForms TreeView, and I don't have time to go back and test against the standard WinForms TreeView.
The problem as I see it is the rather unique dynamics of drag and drop : first the control the drag is coming from continues to capture the mouse until Drop time.
Yes you can put up a context menu strip, or a menustrip, in the DragDrop of the drop-target control event, and set some global variable by selecting one of its items : the problem seems to be it runs on another thread : it's not modal : it doesn't block the rest of the code running in your DragDrop handler from proceeding : in fact, if you put a Console.WriteLine in your context menu selectItem code to print out your choice : you'll find it's written out after the DragDrop completes.
I have one prototype I wrote where I completely bypassed all of the regular WinForms drag and drop : in that prototype I was successful, in doing exactly what you are describing here (and with a much better drag-drop preview image, and a nice option menu that stuck around until you dismissed it). If I have the time I intend to publish that technique here on CP.
Perhaps one of our resident "gurus" will "weigh in" here with some wisdom
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hi Bill,
Thanks again for you're time.
it will be great if you will have the time to post that code, im sure it will help lot's of programmers..
Happy holiday's
Eyal
|
|
|
|
|
Hi Eyalle,
Happy Hanukkah !
eyalle wrote: it will be great if you will have the time to post that code, im sure it will help lot's of programmers..
It will be a few months before I get to this, probably.
Consider the many benefits built into "native" drag-and-drop including (with effort) drag-dropping stuff from one application into another, interacting with the clipboard, the whole DataObject functionality built-in, dropping files or whatever to the desktop, etc.
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Simple question:
How do I position an MDI child form inside the parent form when you call the child form?
Thanks.
|
|
|
|
|
Nevermind. Found a solution.
Changed the startup position property of the childform to "Manual".
Then you can specify the Location of the childForm when it is created.
Any other way to do this?
Thanks.
|
|
|
|
|
I'm working with a third party web service that exposes a status property on one of its classes but this property is in fact another class itself.
Whilst this is no great shakes I'm trying to make use of this web service easier for other developers in the company since the web service is abstracted away and we have our own adapter classes exposing just the properties/methods we need and I have been trying to come up with a way that will allow me to treat the status object much like a enum
What I would like to end up with is something like object.status = StatusAdapter.<value>
which would allow something along the lines of if(foo.Status == StatusAdapter.NotStarted){...}
Before anybody says 'simply use an enum' the reason I am not simply using an enum is that the status data that the web service object represents can be added to by a user at any time which means that I need to create all relevant classes required at run-time. If I used an enum I'd have to change the class library and re-deploy to all applications that use it.
I cannot use an interface as was suggested here [^] simply because the consumers of the class library will not be the ones extending the list of statuses they are just needing to use the statuses I provide.
Any ideas?
|
|
|
|
|
Nathan Gloyn wrote: exposes a status property on one of its classes but this property is in fact another class itself
What do you mean by this excatly, is there a subtype-per-status (good OO, but exposing the problem of translating this to Web/WCF services)? If so the following code will be possible:
ReturnObjectType value = Method();
if(value.Status is StatusType)
{
...
}
Method is the service method invoked
ReturnObjectType is the return type of the Service method call.
StatusType is the type of the status you are looking for.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
No subtype just different property values.
But what I wanted to do is present to users of my class library the values in a form something akin to an enum so that if they create an object and need to set the status of it you wouldn't have to use some sort of 'magic string'
|
|
|
|
|
Pity.
The "magic string" effect is a consequence of [good] advice from Microsoft WRT to maintainability of the service. If they had exposed an enum, adding new values would involve re-gen'ing the client & rebuild, also the numeric values of the enums can change.
Really the message contract types aren't OO'd in the full sense, they are close to object like data bags.
To get round this problem we have converters to convert Data Contracts from the server to pukka objects on the client side. This can be automated with a bit thought.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Make a static class that exposes properties that are of the proper type?
public static class StatusWrapper
{
private static StatusClass notstarted = new StatusClass ( whatever means not started ) ;
public static StatusClass NotStarted { get { return notstarted ; } }
...
}
StatusClass status = StatusWrapper.NotStarted ;
Or, if that's too ummm... static... the wrapper could use a Dictionary to map enumerated values to the status type.
|
|
|
|
|
Thanks PIEBALDconsult both of those answers may be of some use, I must admit to leaning towards the dictionary simply because its a) simple b) can hold as many statuses as the user may want to create.
Admittedly not sure how the end developer may interact with the dictionary but perhaps thats me just being dumb as not coded it yet.
|
|
|
|
|
int[][] num = {
int[]{0, 4, 3, 4},
int[]{1, 3, 0, 0},
int[]{0, 0, 0, 0},
int[]{3, 1, 3, 0}
};
how to use LINQ to found that follow the location (vertical)
0,0
1,0
2,0
3,0
In case, result is 2;
How to count the value larger than zero?
|
|
|
|
|
try:
from n in num
from z in n
where z > 0
select new Point(n,z)
|
|
|
|
|
|
Give this a shot. The tough part was trying to figure out how to get the indexer (using Select func)
var q = from n in num.Select( ( a, index ) => new { IX = index, Arr = a } )
from z in n.Arr
where z > 0
select new {
RootIndex = n.IX,
Value = z
};
This'll flatten out the matrix and only return index/values where value > 0
|
|
|
|
|
I've a application running now with a database connection and wanna make a deployment of it
I tried much things. So that's why I'm asking now is there a easy guide to follow where I can see what to do.
My connection string is hard coded, after I deployed the application it's still hard coded what is the way to let the Data Source (Computer Name) change automaticly to the new computername where it is installed?
(return @"Data Source=KONING-AF02EAF7\SQLEXPRESS;Initial Catalog=KringVrienden;Integrated Security=True";)
SofwareI'm using:
Visual Studio 2008.
SQL Server 2005
SQL Management Server 2005
Please help me.
Dennis,
|
|
|
|
|
I am assuming that each of your target machine has a db server installed.
In your program use System.Environment.MachineName to get the machine name. Use this instead of the hard-coded machine name in your connection string.
Hope this helps.
|
|
|
|
|
Rather than including your development machine name, simply use ".\SQLEXPRESS" or "(local)\SQLEXPRESS" as this will point to instance "SQLEXPRESS" on the local machine.
|
|
|
|
|
what is meant by threading? Muhammad Farooq Qadri, Ghousia Public School and Ghousia Institute of Fast Technology (GIFT), Khuiratta Azad Kashmir
Muhammad Farooq Qadri, Khuiratta AJK
|
|
|
|
|
Dude,
You've posted this FOUR times.
http://msdn.microsoft.com/en-us/library/3e8s7xdd(VS.71).aspx
Regards,
Rob Philpott.
|
|
|
|
|
Well, its like posting the same question several times. I would suggest you go to google and try there, there are over 500,000 articles.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|