I wonder why this question is never addressed

A

Academia

This is a somewhat strange question.

Why is it that no one ever answers when the question relates to merging a
ContextMenuStrip to a MenuStrip?

That's my question.



I've looked on the Internet many times and find many many times when such a
question is asked but never did I find an answer saying "This is how to do
it" or saying "It can't be done".

This NG is great for getting help. How people find the time to help so often
I can't imagine. But very seldom does a reasonable request go un satisfied.
Yet everyone seems to avoid the above mentioned question. Is it a silly
question

The Internet shows that such questions go back to when the tool strips were
released. But no answers. Funny.

Anyway, I don't expect that answer now but do wonder why it is never
addressed.

Do you know?

Thanks



PS If your still with me, why doesn't the Declaration documentation include
ByVal and/or ByRef? In this instance it would be clarifying.

BTW what I writing about is:

ToolStripManager.Merge Method (ToolStrip, ToolStrip)

Visual Basic (Declaration)
Public Shared Function Merge ( _
sourceToolStrip As ToolStrip, _
targetToolStrip As ToolStrip _
) As BooleanImplemented thus:


ToolStripManager.Merge(ContextMenuStrip`, MenuStrip1)

Always returns False
 
G

Guest

PS If your still with me, why doesn't the Declaration documentation
include ByVal and/or ByRef? In this instance it would be clarifying.

Objects are passed ByRef in VB.NET. So ByVal is a moot point.

BTW what I writing about is:

ToolStripManager.Merge Method (ToolStrip, ToolStrip)

Visual Basic (Declaration)
Public Shared Function Merge ( _
sourceToolStrip As ToolStrip, _
targetToolStrip As ToolStrip _
) As BooleanImplemented thus:


ToolStripManager.Merge(ContextMenuStrip`, MenuStrip1)


Interesting, not sure why it won't work, but do you have an MSDN
account? If you post with your MSDN account, a MS support representative
will reply to your message. That way you maybe able to get an answer
straight from the horses mouth :)
 
J

Jack Jackson

No, it is not moot.

Dim ts as New ToolStrip

SomeRoutine(ts)
ts.Name = "MyName"

Public Sub SomeRoutine(ByVal tstrip As ToolStrip)
tstrip = Nothing

Public Sub SomeRoutine(ByRef tstrip As ToolStrip)
tstrip = Nothing

In the first case (ByVal), changing tstrip in SomeRoutine has no
effect on the caller.
In the second case (ByRef), changing tstrip in SomeRoutine also
changes ts in the caller, and the setting of ts.Name will trap.
 
A

Academia

Spam Catcher said:
Objects are passed ByRef in VB.NET.

do you mean all system methods use ByRef

So ByVal is a moot point.




Interesting, not sure why it won't work, but do you have an MSDN
account? If you post with your MSDN account, a MS support representative
will reply to your message. That way you maybe able to get an answer
straight from the horses mouth :)

no I don't but it's a very much referenced problem that never seems to get
answered.

thanks
 
G

Guest

No, it is not moot.

Dim ts as New ToolStrip

SomeRoutine(ts)
ts.Name = "MyName"

Public Sub SomeRoutine(ByVal tstrip As ToolStrip)
tstrip = Nothing

Public Sub SomeRoutine(ByRef tstrip As ToolStrip)
tstrip = Nothing

In the first case (ByVal), changing tstrip in SomeRoutine has no
effect on the caller.
In the second case (ByRef), changing tstrip in SomeRoutine also
changes ts in the caller, and the setting of ts.Name will trap.

Objects in .NET are passed by reference. So both have the same effect.
 
G

Guest

Objects in .NET are passed by reference. So both have the same effect.

I just re-read your code, yes you're right ByRef does have a slightly
different behaviour in your code.

ByVal will duplicate an object's pointer while ByRef will use the same
pointer.

However, the pointers will access the same instance of the object in the
heap.

I think this is the only difference when passing objects ByVal vs. ByRef -
the object's pointer is duplicated but you're still passing around the same
instance.
 
A

Academia

Spam Catcher said:
I just re-read your code, yes you're right ByRef does have a slightly
different behaviour in your code.

ByVal will duplicate an object's pointer while ByRef will use the same
pointer.

However, the pointers will access the same instance of the object in the
heap.

I think this is the only difference when passing objects ByVal vs. ByRef -
the object's pointer is duplicated but you're still passing around the
same
instance.

I think the big difference occurs if the routine changes the value of the
pointer so that it points to a new object

 
O

\(O\)enone

Spam said:
Objects in .NET are passed by reference. So both have the same effect.

Objects are indeed passed by reference. But object references themselves may
be passed either by reference or by value.

When you pass an object using a ByVal parameter, a new object reference
(pointing to the same object) is created. Changing this object reference (by
pointing it to a different object or to Nothing) will have no effect on the
corresponding object reference in the calling procedure.

When you pass an object using a ByRef parameter, you pass a reference to the
object reference. It is therefore the same object reference as used in the
calling procedure. If you change this object reference, the calling
procedure's reference will be changed too.
 
C

Chris Dunaway

Objects in .NET are passed by reference. So both have the same effect.

No, they're not. The default passing mechanism is ByVal unless you
use the ByRef keyword.

Chris
 
K

Kerry Moorman

Chris,

Are you sure you want to say that OBJECTS are passed by value?

Kerry Moorman
 
A

Armin Zingler

Kerry Moorman said:
Chris,

Are you sure you want to say that OBJECTS are passed by value?

Kerry Moorman

Maybe I missed something in this thread, but...

- Everything is an object
- There are reference types and value types.

- Value type + ByVal: Copy of the object is passed on the stack
- Value type + ByRef: (Copy of) the reference to the object is
passed on the stack
- Reference type + ByVal: Reference to the object is passed
on the stack
- Reference type + ByRef: Reference to a reference to the object
is passed on the stack


Armin
 
C

Chris Dunaway

Are you sure you want to say that OBJECTS are passed by value?
Well, objects themselves are never passed (in the case of reference
types) but a reference to the object is passed. And by default, the
reference is passed by value unless the ByRef keyword is used.

Chris
 
A

Academia

Andrew Morton said:

He ended up doing
editMenu.DropDown = contextMenuStrip
not really merging. Anything that was on the DropDown is no longer on it.

q=cache:b87vpsQ3ECYJ:forums.microsoft.com/MSDN/ShowPost.aspx%3FPostID%3D379041%26SiteID%3D1+merge+ContextMenuStrip+MenuStrip&hl=en&ct=clnk&cd=1

Same as above


Thanks but I had seen that site and many many more before.

I believe it can't be done. At leasts not with ToolStripManager.Merge

Thanks for looking
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top