We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridDataboundGrid: DragAndDrop

Thread ID:

Created:

Updated:

Platform:

Replies:

96037 Aug 17,2010 12:51 PM Aug 26,2010 06:07 AM ASP.NET Web Forms (Classic) 6
loading
Tags: GridGroupingControl
Dani Knopf
Asked On August 17, 2010 12:51 PM

Hi

We use the GridDataboundGrid in connection with businessObjects and we need to implement drag and drop behaviour to change the order of the rows. (No drag and drop for single cells, we just want to add the row order).

As far as I know, I would have to change the order of the underlying datasource, which is not a problem. Dragging seems to be supported and the DragDrop events are triggered. Unfortunately, I dont know how to use these events (see code below) to get the rowIndex of the row to move and the rowIndex where the row is to be dropped.

I appreciate any help. Thanks


--------- Code snippets -----------

this.DragEnter += new DragEventHandler(CustomGrid_DragEnter);
this.DragDrop += new DragEventHandler(CustomGrid_DragDrop);

void CustomGrid_DragDrop(object sender, DragEventArgs e)
{
object whatToDoWithThis = e.Data;
e.Effect = DragDropEffects.Move;

}

void CustomGrid_DragEnter(object sender, DragEventArgs e)
{
object whatToDoWithThis = e.Data;
}

Dani Knopf
Replied On August 20, 2010 02:53 AM

Hi

Some additional information that may help you.
I dont want to enable drag n' drop for single cells, only for entire rows. The drag 'n drop functionality should only be used to change the order of the underlying datasource.

When I now select a row and I start to drag it, the DragEnter event is fired. I figured that I could access the row index via Model.CurrentCellInfo.RowIndex.

My problem concerns the DragDrop event. Firstly, I dont know how to access the target rowIndex (also via Model.CurrentCellInfo.RowIndex, has it already changed?).
Secondly, the event does not get fired but the following exception occurs:
Object of type 'System.DBNull' cannot be converted to type 'System.Guid'

We uses business objects (Entity framework objects) that have quite a few nullable properties such as (Guid?, short?) etc.

How can I ensure the event is always fired and how do I access the target rowIndex.

Thanks in advance for your effort.

Dan

Dani Knopf
Replied On August 20, 2010 03:55 AM

Hi

I believe I could use the OnMouseUp event (or override the protected method in a custom grid) to access the target row index sorting of the underlying datasource.
However, my main problem remains: an exception (
Object of type 'System.DBNull' cannot be converted to type 'System.Guid'
) occurs when I start dragging and the OnMouseUp event is not even triggered!

What can I do about this?



By the way, the following knowledge article explains drag n drop, but unfortunately the attached example is no longer available.

Thanks for any help.
Dan


Nirmal Raja [Syncfusion]
Replied On August 24, 2010 02:03 AM

Hi Dan,

Sorry for the relay in response.

The records can be moved after the drag and drop by changing the values from the currency manager, updating the DataRowView and then the grid has to be updated to the data source.

Please refer the forum page from the below location:
http://www.syncfusion.com/support/forums/grouping-windows/73068

Let me know if you have any queries.

Regards,
Nirmal

Dani Knopf
Replied On August 24, 2010 03:28 AM

Hi

First of all, thank you for your reply.
I already know that I have to sort the underlying datasource (in my case a List filled with entity objects). This is not causing any problems.

I use the DragEnter event to get the index of the row to move and
the OnMouseUp event to actually move the selected row. However, as I explained in a previous post, the OnMouseUp event is never triggered, because an exception is shown ("Object of type 'System.DBNull' cannot be converted to type 'System.Guid')

The flow of events (as far as I have seen) is as follows:
1. I use the mouse to starte dragging a row vie row header!
2. DragEnter is called!
3. OnCurrentCellErrorMessage event is called (why?? the underlying object is valid)
4. Strangely, in my case, the value of the property in the bound object is set to null: The name property is suddenly empty.


-----------Below the stacktrace (caught in OnCurrentCellErrorMessage:
> PresentationLayer.exe!Buchi.KjeLink.PresentationLayer.ViewControls.Grid.CustomGrid.OnCurrentCellErrorMessage(Syncfusion.Windows.Forms.Grid.GridCurrentCellErrorMessageEventArgs e = {Syncfusion.Windows.Forms.Grid.GridCurrentCellErrorMessageEventArgs}) Line 99 C#
Syncfusion.Grid.Windows.dll!Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellErrorMessage(Syncfusion.Windows.Forms.Grid.GridCurrentCellErrorMessageEventArgs e = {Syncfusion.Windows.Forms.Grid.GridCurrentCellErrorMessageEventArgs}) + 0x3d bytes
Syncfusion.Grid.Windows.dll!Syncfusion.Windows.Forms.Grid.GridCurrentCell.DisplayWarningText(string message) + 0xc1 bytes
Syncfusion.Grid.Windows.dll!Syncfusion.Windows.Forms.Grid.GridControlBase.OnMouseDown(System.Windows.Forms.MouseEventArgs e) + 0x267 bytes
Syncfusion.Grid.Windows.dll!Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.OnMouseDown(System.Windows.Forms.MouseEventArgs e) + 0x6 bytes



------------- The debug output: ------------

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.ObjectStorage.CompareValueTo(Int32 recordNo1, Object value)
at System.Data.Index.FindNodeByKey(Object originalKey)
at System.Data.DataView.System.ComponentModel.IBindingList.Find(PropertyDescriptor property, Object key)
at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key)
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0
System.ArgumentException: Object of type 'System.DBNull' cannot be converted to type 'System.Guid'.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly)
at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType)
at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.ChangeCell(Int32 rowIndex, Int32 colIndex, GridStyleInfo style)
at Syncfusion.Windows.Forms.Grid.GridVolatileData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfo value)
at Syncfusion.Windows.Forms.Grid.GridStyleInfoIdentity.OnStyleChanged(StyleInfoBase style, StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.EndUpdate()
at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle)
catched at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle) in :line 0
System.ArgumentException: Object of type 'System.DBNull' cannot be converted to type 'System.Guid'.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly)
at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType)
at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.ChangeCell(Int32 rowIndex, Int32 colIndex, GridStyleInfo style)
at Syncfusion.Windows.Forms.Grid.GridVolatileData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfo value)
at Syncfusion.Windows.Forms.Grid.GridStyleInfoIdentity.OnStyleChanged(StyleInfoBase style, StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.EndUpdate()
at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle)
System.ArgumentException: Object of type 'System.DBNull' cannot be converted to type 'System.Guid'.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.SaveCellInfo(GridSaveCellInfoEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly)
at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType)
at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.ChangeCell(Int32 rowIndex, Int32 colIndex, GridStyleInfo style)
at Syncfusion.Windows.Forms.Grid.GridVolatileData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfo value)
at Syncfusion.Windows.Forms.Grid.GridStyleInfoIdentity.OnStyleChanged(StyleInfoBase style, StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.OnStyleChanged(StyleInfoProperty sip)
at Syncfusion.Styles.StyleInfoBase.EndUpdate()
at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text, Int32 textInfo)
at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle)
at Syncfusion.Windows.Forms.Grid.GridDataBoundGridModel.OnClearingCells(GridClearingCellsEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle)
at Syncfusion.Windows.Forms.Grid.GridOleDataSourceMouseController.DndStartDragDrop(Int32 rowIndex, Int32 colIndex)
at Syncfusion.Windows.Forms.Grid.GridOleDataSourceMouseController.MouseDown(MouseEventArgs e)
at Syncfusion.Windows.Forms.MouseControllerDispatcher.ProcessMouseDown(MouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControllMouseControllerDispatcher.ScrollControlBeforeMouseDown(Object sender, CancelMouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControl.OnScrollControlMouseDown(CancelMouseEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnScrollControlMouseDown(CancelMouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControl.RaiseCancelMouseEvent(MouseEventArgs e, CancelMouseDelegate d)
catched at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle) in :line 0
catched at Syncfusion.Windows.Forms.ScrollControl.RaiseCancelMouseEvent(MouseEventArgs e, CancelMouseDelegate d) in :line 0
The thread '' (0xd0c) has exited with code 0 (0x0).

Dani Knopf
Replied On August 24, 2010 03:37 AM

I am pretty sure it has something to do with the fact that we use a listwith business objects (from the entity framework, .Net 4.0 Visual Studio 2010 Professional) and not datatables as datasource.

This is a major issue and rather urgen. Please it would be very nice if you could help us.

Thanks in advance.

Nirmal Raja [Syncfusion]
Replied On August 26, 2010 06:07 AM

Hi Dan,

It seems that you have posted a similar issue in an incident which has been updated with a solution. Please follow it up in that incident and the incident ID is 71410.

Let me know if you have any other concern.

Regards,
Nirmal

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;