|
Are there any reasons why you loading the assembly?
Have a look at my Plugin Manager article. It mite serve your purpose.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thank you very much,leppie.
|
|
|
|
|
Hello,
I'm recently implementing the drag and drop function of listview. I just need to drag-drop item inside listveiw, e.g, drag one item upper or lower.
However, my code didn't work so good, does any experts got this experience?
The main difficult part for me is to calulate the position of item. for example:
If I drag item 5 over item 3 and then release mouse, item 5 suppose will be placed at the location of item 3, and it works ,item 3 became item 4;
If I drag item 1 over item 3 and then release mouse, item 1 suppose will be placed at the location of item 3, but it always place at location of item 2.
I don't know how to solve it at all, hope someone can help me and show me the example code~~
Thank you
|
|
|
|
|
Simple. The DragOverEventArgs (for the DragOver event) contains an X and Y coordinate in screen coordinates. First, get the window coordinates by a simple translation:
Point p = myListView.PointToClient(new Point(args.X, args.Y)); Next, get the item at that point in the ListView and add the ListViewItem you're dragging below it.:
ListViewItem item = myListView.GetItemAt(p.X, p.Y);
if (item != null)
{
myListView.Items.Insert(item.Index + 1, draggedItem);
} Of course, getting the ListViewItem you're dragging is implementation-specific, and it appears you've already got that part figured out.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks for your reply, Stewart.
<small>Heath Stewart wrote:</small>
myListView.Items.Insert(item.Index + 1, draggedItem);
my codes are little same as that you provided,however, there is a problem that it will always insert the new item below the target item.
My code :
private void List_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
Point cp = List.PointToClient(new Point(e.X, e.Y));
ListViewItem dragToItem = List.GetItemAt(cp.X, cp.Y);
int num = List.SelectedItems.Count;
int locationIndex = dragToItem.Index;
for(int i=0; i<<num; i++)
{
ListViewItem dragItem = List.SelectedItems[i];
ListViewItem insertItem = (ListViewItem)dragItem.Clone();
List.Items.Insert(locationIndex, insertItem);
locationIndex++;
}
foreach(ListViewItem olditem in List.SelectedItems)
{
List.Items.Remove(olditem);
}
}
I felt some part of my code can be improved, but could you check what's worng with me?
|
|
|
|
|
For one, your for loop contains a bit-shift operator (<<) instead of a comparison operator (<). Other than that, while perhaps not the most efficient designer, it looks okay. Just step through it in the debugger and see what's going wrong. After all, good debugging skills is half the battle of good development.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Ops, that's just a typing mistake.
ok, I give up that,
now I hope to show a line between ListView items that reperesents the location of being insert.
e.g. if I dragged an item to item 5 location, the line shows between item 4 and 5.
Do you have any idea to do that?
Pls help, thank you~
|
|
|
|
|
You have to custom draw a line using the Graphics class between the two items (by centering a line between the bottom of one and the top of the other, such that a line would (normally) be 2 pixels wide - 1 pixel overlapping the bottom of the upper ListViewItem , and 1 pixel overlapping the top of the lower ListViewItem ).
You can get a reference to a Graphics object by either handling the Paint event and using several variables to track when you should draw a line and where, or (preferrably) you can do it by calling ListView.CreateGraphics (actually inheritted from Control.CreateGraphics ) to get the Graphics object and draw a line in the appropriate place. Just be sure to draw it uniformly. That is, make sure that you are consistent in where you draw it in relation to the insertion point.
I know there are several good articles on this subject (both with lists and trees) on CodeProject. You really should try searching for a solution here on CP.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey dudes,
I'm prepared to be shot down here, but...
Is it possible to add C# functions/files
into a C++ Project in Visual Studio .NET??
Any assistance would be
greatly appreciated.
SLY.
|
|
|
|
|
|
Thanks for the quick reply That should work great!
SLY.
|
|
|
|
|
|
hi, i'm totally flabberghasted by the event model, at least for what i want to do which is to copy the event delegate (as part of copying a template control).
the short story is, copying the event delegate works no problem from within the scope of the class which defines the event, but the compiler does not let you do it from outside the class-- similar to the behavior of a field marked "private", although the event is clearly public.
can anybody clue me into the rhyme or reason of this behavior? it presumably is related to the "non-field" implemplementations of events using add and remove, but i still don't understand why the support isnt there for me to determine how events were implemented in the class and clone them from one instance to another.
thanks in advance! here's the snippet:
<br />
public class Bar <br />
{<br />
public event EventHandler BarEvent; <br />
}<br />
<br />
public class Foo <br />
{<br />
public event EventHandler MyEvent; <br />
Foo foo; <br />
Bar bar, foobar; <br />
<br />
this.MyEvent = foo.MyEvent;
foo.MyEvent = this.MyEvent;
bar.BarEvent = foobar.BarEvent;
}<br />
|
|
|
|
|
You should check-out MSDN for this: http://msdn.microsoft.com/library/en-us/cpguide/html/cpconevents.asp[^]
Essentially, as is common in COM and other platforms as well, think of an event as a collection of delegates (managed function pointers). For this reason, you use incremental (+=) and decremental (-=) assignment operators like all the examples use in the .NET Framework SDK documentation.
You can't directly assign (=) your event handler to another class's event. That's why your getting the compiler error when you're doing it to another class and not your own (this). You should be doing it to your own event anyway. Events are actually based on MulticastDelegate derivatives, because when you use the delegate keyword, it will actually derive from MulticastDelegate . See the docs for details.
In comparison, you can use delegates as callback functions throughout your app, but events really aren't callbacks. As I said before, they're more like a collection of callbacks.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
How can I repait the Caption area of a window customized? I can't get the graphics of caption area.
|
|
|
|
|
You have to get low-level, and deal with Windows API calls and messages, like WM_NCPAINT. Plus, you'll have to fight w/ some painting anomalies. In short, it's no fun.
|
|
|
|
|
|
Check-out this article on MSDN that uses BITS (only with Win2K, WinXP and newer, but could be written using a standard WebRequest ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If I have loaded a dll in my program, how can I free it?
Andyniyong waiting for your answer.
|
|
|
|
|
You can't.
To unload a dll, you must load it in a separate application domain, so when you unload your second application domain, the dll will also unload...
Free your mind...
|
|
|
|
|
Hi, All
I do have two questions :
1.) Is there any possibility to derive a class from the component class and drag it into a form (like a usercontrol)?
2.) If so i wonder is someone have build some kind of GraphicalUserComponent class, a class wihout a window handle.
(define Email (lambda ()
elacroix@devmesh.com))
Im not a church numeral im a free variable
|
|
|
|
|
Regards everybuddy,
Except timer method, how can I monitor a variable (for example a string) and call a method as soon as and each time it changes?
Thanks for any note and best wishes
-nSun
---
"Art happens when you least expect it"
|
|
|
|
|
I don't think you can attach an event to a variable in C#.
Of course you can theoritically create your own variable class which raises an event everytime it is changed.
However, I probably will just create a property for the variable which will call a method every time it is set.
Create your class if you need to use many variables, otherwise create a property.
Hope it helps.
|
|
|
|
|
Yes, Propert method is greate but in some cases creating a new class will be more effective. Thanks buddy
---
"Art happens when you least expect it"
|
|
|
|
|
Yes, Property method is greate but in some cases creating a new class will be more effective. Thanks buddy
---
"Art happens when you least expect it"
|
|
|
|