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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

can you restrict draging and dropping?

Thread ID:

Created:

Updated:

Platform:

Replies:

28116 Apr 25,2005 01:32 PM UTC Apr 26,2005 07:16 PM UTC WinForms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 25, 2005 01:32 PM UTC

Can you have a grid allows drag and drop, but does not allow a user to select data from the last two rows?

Administrator [Syncfusion]
Replied On April 25, 2005 02:21 PM UTC

You can avoid the user seecting cells from the last 2 rows by using the grid.Model.SelectionChanging event.
//subscribe to the event
this.gridDataBoundGrid1.Model.SelectionChanging += new GridSelectionChangingEventHandler(Model_SelectionChanging);


//the handler
private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
	GridModel model = sender as GridModel;
	if(model != null)
	{
		if(e.Range != null && e.Range.IntersectsWith(GridRangeInfo.Rows(model.RowCount-1, model.RowCount)))
		{
			e.Cancel = true;
		}
	}
}

And if your user cannot select cells in teh last two rows, he will not be able to drag them.

	 

Administrator [Syncfusion]
Replied On April 25, 2005 04:03 PM UTC

the line I am having troble switching to vb is GridModel model = sender as GridModel; I have tried Dim model As GridModel = sender as GridModel and Dim model As GridModel = sender.GridModel On the first one, "as gridmodel" is erroring saying end of statement expected, and the second one compiles but then then I cant select anything. Here is my code (in form load) AddHandler GridDataBoundGrid1.Model.SelectionChanging, AddressOf Model_SelectionChanging Private Sub Model_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs) Dim model As GridModel = sender.GridModel ''if model is something then If Not model Is Nothing Then ''if range is something and the intersection is the last two rows If Not (e.Range Is Nothing) And e.Range.IntersectsWith(GridRangeInfo.Rows(model.RowCount - 1, model.RowCount)) Then e.Cancel = True End If End If End Sub

Administrator [Syncfusion]
Replied On April 26, 2005 12:32 AM UTC

Hi Bob, Here is the VB.NET code: AddHandler Me.gridDataBoundGrid1.Model.SelectionChanging, AddressOf Model_SelectionChanging '' Handler.. Private Sub Model_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs) Dim model As GridModel = CType(sender, GridModel) If Not (model Is Nothing) Then If Not (e.Range Is Nothing) AndAlso e.Range.IntersectsWith(GridRangeInfo.Rows(model.RowCount - 1, model.RowCount)) Then e.Cancel = True End If End If End Sub Regards, Jay N

Administrator [Syncfusion]
Replied On April 26, 2005 07:16 PM UTC

Ah, I was close but no cigar. Thanks for the corrected code Jay.

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.

Warning Icon 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.Close Icon

;