Issue with DragDropBlock?

Posted by: alkesh on 8 September 2017, 12:45 pm EST

  • Posted 8 September 2017, 12:45 pm EST



    I am developing a schedule grid using the farpoint spread sheet in X(dates) by Y(time of the day in 5 minutes solts) format. User can schedule items by dragging and dropping it to a different location. I have scheduled the items based on the location and on the grid and spanned the item depending on the item length. An item is identified by displaying the spanned cell in different color.

    When a user drags and drops an item and a item already exits then that item should be replace by the item just dropped, whereever it may be.

    Scenario and Issue:

    There is an item already scheduled at cell location (5,5) and its length is say 6. So it will span in X direction till (5,10). Now if  I drag another item from the grid which has same length 6 and If it exactly operlaps, the mouse pointer is appended by a rectangle, indicating that you can drop the item at that location. And everything works well. 

    Now when I move by cursor one pixel to right or left the rectangle turns into a black circle with a line across in it indicating that this item cannot be dropped at that location. This also happens when the length of items is different. Eg. When the length of the item on the grid is 10 and the length of the item being dropped is 5. The underlying item does not accepts the item being drop on itself. Can you please let me the solution for this?

    Please note, I have a requirement that the user can schedule items anywhere in the grid and the I have written a custom logic to schedule items and span them.

    Please let me know in case you need any further details.

    Thanks & Regards,


  • Replied 8 September 2017, 12:45 pm EST


    We would need to see the code you are using to try to implement this. Could you post a small zipped project reproducing this issue for us to debug?

  • Replied 8 September 2017, 12:45 pm EST


    I would have to spend substantial time to make a separate project which you have asked. I will do that later, if the following does'nt help.

    Please refer screen shot

    Form laod....

    Setting up rows headers and column headers and loading items (we call it Plays).

    It also calls PresentGrid()

    <FONT color=#0000ff size=2>

    public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> PresentGrid()


    </FONT><FONT color=#0000ff size=2>foreach</FONT><FONT size=2>(ScheduleSlot t_ScheduleSlot </FONT><FONT color=#0000ff size=2>in</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.ScheduleSlotList)






    <FONT size=2>ScheduleSlotList is the collection of the ScheduleSlot on the grid. Each ScheduleSlot object has information such that PresentGrid() can decide where to place it.</FONT>

    <FONT color=#0000ff size=2>

    protected</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> Schedule(ScheduleSlot argScheduleSlot)


    //ColumnSpan depends upon the length of the play</FONT><FONT color=#0000ff size=2></FONT>

    <FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].ColumnSpan = </FONT>

    <FONT size=2>25</FONT>

    <FONT color=#0000ff size=2>//Assign color to the slot</FONT>

    <FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].BackColor = Color.Yellow</FONT>

    <FONT color=#0000ff size=2>//Display text in the slot</FONT>

    <FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].Value = argScheduleSlot.DisplayText;


    <FONT size=2>

    </FONT><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> DragDropBlock(</FONT><FONT color=#0000ff size=2>object</FONT><FONT size=2> sender, DragDropBlockEventArgs e)


    </FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot!= </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>)


    </FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.HandleConflict(m_ScheduleSlot,e.DestinationRowBegin,e.DestinationColumnBegin,</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot.SchedulePlay.PlayLength).Equals(DialogResult.Yes))


    <FONT color=#0000ff size=2>this</FONT><FONT size=2>.ResetSlotAppearance(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot);

    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot.SchedulePlay.StartTime = </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot.GetColDateTime(e.DestinationColumnBegin);

    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot.SchedulePlay.PlayDate = </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.m_ScheduleSlot.GetRowDateTime(e.DestinationRowBegin);

    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.PresentGrid();

    </FONT><FONT size=2>}

    e.Cancel = </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>;


    <FONT color=#0000ff size=2>

    public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> ResetSlotAppearance(ScheduleSlot argScheduleSlot)


    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].ColumnSpan = 1;

    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].BackColor = Color.White;

    </FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].Value = String.Empty;



    <FONT size=2>Please note that <FONT size=2>DragDropBlock itself is not getting fired when I drag a slot over another slot.</FONT></FONT>

    <FONT size=2><FONT size=2>I hope my previous post and this one should help. Please let me know in case of any questions.


    <FONT size=2></FONT> 

  • Replied 8 September 2017, 12:45 pm EST


    This is the intended behavior. The Spread is not going to allow a smaller span to overwrite a larger span. This will mess up how the span is displayed. Spread would not how you want the two spans to be in this area after the drag, so we do not allow it. I would suggest not using spans, but rather merge data together in the cells to make it look like the cells are spanned.

  • Replied 8 September 2017, 12:45 pm EST

    <FONT face=Verdana size=2>Hi Scotts,</FONT>

    <FONT face=Verdana size=2>I am relatively new to farpoint. Can you please let me know how do we merge data in the cells so that it appears as it is spanned (without actually spanning the cells)?</FONT>

    <FONT face=Verdana size=2>Thanks & Regards,</FONT>

    <FONT face=Verdana size=2>Alkesh Patel</FONT>

  • Replied 8 September 2017, 12:45 pm EST


    If you have cells next to each other with the same data and set the SetColumnMerge and/or SetRowMerge methods, then Spread will automatically group those like data togeter and display it once (like a span) without an actual span.

  • Replied 8 September 2017, 12:45 pm EST

    <FONT face=Verdana size=2>Thank you for your inputs.</FONT>

    <FONT face=Verdana size=2>I managed to pull off almost similar functionality with SetRowMerge () method you suggested.</FONT>

    <FONT face=Verdana size=2>Here is the snippet of code I modified</FONT>

    <FONT size=2><FONT face=Verdana><FONT color=#0000ff>int</FONT> t_ColCount = <FONT color=#0000ff>this</FONT></FONT><FONT face=Verdana>.NbrOfColsInSlot(argScheduleSlot);</FONT></FONT>

    <FONT face=Verdana size=2>String t_DisplayString = argScheduleSlot.DisplayText;</FONT>

    <FONT size=2><FONT face=Verdana><FONT color=#0000ff>for</FONT>(<FONT color=#0000ff>int</FONT></FONT><FONT face=Verdana> i = argScheduleSlot.ColStart; i <= (argScheduleSlot.ColStart + t_ColCount -1); i++ )</FONT></FONT>

    <FONT face=Verdana size=2>{</FONT>

    <FONT face=Verdana size=2>t_DisplayString = String.Concat(t_DisplayString,"\t",t_DisplayString);</FONT>

    <FONT size=2><FONT face=Verdana color=#0000ff>this</FONT><FONT face=Verdana>.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,i].BackColor = argScheduleSlot.SchedulePlay.ScheduleItem.Color;</FONT></FONT>

    <FONT face=Verdana size=2>}</FONT>

    <FONT face=Verdana size=2>t_DisplayString.TrimEnd('\t');</FONT>

    <FONT face=Verdana><FONT size=2><FONT color=#0000ff>this</FONT>.fpScheduleSpreadSheet.SetClipValue(argScheduleSlot.RowStart,argScheduleSlot.ColStart, 1, t_ColCount, t_DisplayString);</FONT></FONT>

    <FONT face=Verdana size=2></FONT> 

    <FONT face=Verdana size=2>I am facing couple of issued</FONT>

    <FONT face=Verdana size=2>--> I want the rows of the grid to be locked. When I do that SetClip() method doesnot seem to be working.</FONT>

    <FONT face=Verdana size=2>Thoughts?</FONT>

    <FONT face=Verdana size=2>--> Is there a straight way to select the entire range of merged cells?</FONT>

    <FONT face=Verdana size=2>I mean if I select 6th cell of an item(play) the entire play(item) would get selected.</FONT>

    <FONT face=Verdana size=2>Thanks once again for your help</FONT>

    <FONT face=Verdana size=2>Alkesh Patel</FONT>

  • Replied 8 September 2017, 12:45 pm EST


    1) You can set the Protect property of the Spread to False before calling SetClip to get the data into the Spread. Then you can set the Protect property back to True, to lock all the cells marked with Locked=True.

    2) There is not a way to select all cells in a range. The difference between this and spans is this has all cells working independently of each other.

  • Replied 8 September 2017, 12:45 pm EST

    Please find the screenshot. Missed it earlier

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels