Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OnEvent philosophy

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Eric



Joined: 06 Oct 2005
Posts: 15
Location: Regensburg, Germany

PostPosted: Tue Oct 25, 2005 5:00 pm    Post subject: OnEvent philosophy Reply with quote

I would like to understand why the onEvent methods are defined in virtualtree as protected and/or internal and not public.

For example, I read in your help, Adding drag and drop support.

Quote:
If the data source lists do not support Add and Remove then you will need to handle the RowDrop event (or override the OnRowDrop method) to manage this programmatically.


and then in VirtualTree.OnRowDrop method

Code:
protected internal virtual void OnRowDrop


how can I override that ? With such a declaration, I should be able to make my own virtualtree class that derive from VirtualTree and still in the same assembly! That sounds very limited...
What is the reason for that?


Anyway, I am currently looking how I can use the drag & drop from nodes (objectbinding) in my trees. The event DragEnter occurs correclty but none of the DragDrop nor RowDrop event occurs when I leave my object in another node although the drop cursor is here.
And then, my dragged node is the selected one (virtualtree.selectedItem). But how can I catch the destination node where I leave my selected one?

Thanks for your replies.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Oct 25, 2005 10:42 pm    Post subject: Re: OnEvent philosophy Reply with quote

Eric wrote:

I would like to understand why the onEvent methods are defined in virtualtree as protected and/or internal and not public.


Defining OnEvent methods as protected is standard .NET practice. This is because these methods are not typically designed to be called by objects outside the class. Some VirtualTree methods also have the internal modifier because they are called by other closely related classes defined in the same project (for instance RowWidget).

Quote:
how can I override that ? With such a declaration, I should be able to make my own virtualtree class that derive from VirtualTree and still in the same assembly! That sounds very limited...
What is the reason for that?


You override methods marked protected internal the same way as you do protected methods (ie you don't put the internal keyword in overridden method signature). Unfortunately the Visual Studio code completion wizard is not very smart and sticks the internal modifier in when you override one of these methods. Just take it out and you'll be OK.

Quote:
Anyway, I am currently looking how I can use the drag & drop from nodes (objectbinding) in my trees. The event DragEnter occurs correclty but none of the DragDrop nor RowDrop event occurs when I leave my object in another node although the drop cursor is here.
And then, my dragged node is the selected one (virtualtree.selectedItem). But how can I catch the destination node where I leave my selected one?


Make sure that you don't override or handle the DragEnter, DragOver or DragDrop events/methods directly yourself - or you may interfere with the way in which VirtualTree handles drag and drop of rows for you. Check that the target rows (ie the rows you are trying to drop on to) have AllowDropOnRow property set to true in the RowBindings. If you haven't got this set properly you should see the drag cursor contains a black circle with a diagonal line - indicating that the current drag selection can't be dropped here.

If you are still having problems then maybe put together a sample project which illustrates your problem and email it to us a support@infralution.com and we will take a closer look.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Eric



Joined: 06 Oct 2005
Posts: 15
Location: Regensburg, Germany

PostPosted: Wed Oct 26, 2005 1:23 pm    Post subject: Override Drag&Drop Reply with quote

Thanks for your reply.

By desactivating the override of the Drag/Drop events, it is working on the GUI, but only on the GUI. I suppose that the default handling of drag and drop of rows of Virtualtree uptades the Child and Parent Properties, isn't it?

As my object node has futhermore datarow from my DataSet, I need to assure the move of the object in our databinding (where many tables are linked together).
So I need to override these methods, but also need to have the default drag&drop behavior of the virtualtree. How can I made that? Is there something to call for these events similar to the following for GetCellData?
Code:
VirtualTree virtualtree = (VirtualTree)sender;
RowBinding rowbind = virtualtree.GetRowBinding(e.Row);
rowbind.GetCellData(e.Row, e.Column, e.CellData);


Or do I have to define my own widget as you've done in your sample (CustomCellWidget) ?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Oct 26, 2005 11:00 pm    Post subject: Reply with quote

I'm not sure I fully understand your question. Typically if you need to do other checks before allowing a drag selection to be dropped you would do this in GetAllowedDropLocations. You can, as shown below, use the row bindings default behaviour by calling the corresponding method. You can then check for cases where you don't want to allow dropping and set the AllowedDropLocations to None.

Code:
private void _virtualTree_GetAllowedRowDropLocations(object sender, GetAllowedRowDropLocationsEventArgs e)
{
    RowBinding binding = _virtualTree.GetRowBinding(e.Row);
    binding.GetAllowedDropLocations(e.Row, e.Data);
    if (e.Row.Item is CantDropOnThis)
    {
        e.AllowedDropLocations = RowDropLocation.None;
    }
}



If you need to customize what happens when the data is dropped then you need to handle the RowDrop event. Again you could call the row binding OnDrop method to implement the default behaviour.

Code:
private void _virtualTree_RowDrop(object sender, RowDropEventArgs e)
{
    Row[] dropRows = (Row[])data.GetData(typeof(Row[]));

    // check that we are dropping rows
    //
    if (dropRows != null)
    {
        // insert the dropped rows under e.Row
    }
}


Note that if you handle these events you need to check the data being dropped is a type you want to handle. These events will be called both when internal rows are being dragged and when data from external controls/applications is dragged over the tree. If it is row data being dropped then the drag data will be an array of Rows.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Eric



Joined: 06 Oct 2005
Posts: 15
Location: Regensburg, Germany

PostPosted: Fri Oct 28, 2005 4:34 pm    Post subject: Reply with quote

ok, I've played with GetAllowedRowDropLocations and it fills my needs for checking the nodes (if condition is true, e.AllowedDropLocations = RowDropLocation.OnRow, else, e.AllowedDropLocations = RowDropLocation.None )

I need now to modify the dragged node/row between the drag and the drop. I suppose I have to do that in RowDrop as you said. I catch the dragged row in GetAllowedDrag, but how can I say to the dropped row that the row to be drop is not the dragged row, but something I need to specify ?

Or was it the meaning of the following line: (e refer to the drop row)
Row[] dropRows = (Row[])data.GetData(typeof(Row[]));
data refer to e.Data or should it be something else ?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Oct 28, 2005 10:41 pm    Post subject: Reply with quote

Eric wrote:

Or was it the meaning of the following line: (e refer to the drop row)
Row[] dropRows = (Row[])data.GetData(typeof(Row[]));
data refer to e.Data or should it be something else ?


Sorry that should have been:

Row[] dropRows = (Row[])e.Data.GetData(typeof(Row[]));

This gives you the list of rows being dropped.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group