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. Image for the cookie policy date

can you restrict draging and dropping?

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

4 Replies

AD Administrator Syncfusion Team April 25, 2005 09:21 AM

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.

	
            


AD Administrator Syncfusion Team April 25, 2005 11:03 AM

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


AD Administrator Syncfusion Team April 25, 2005 07:32 PM

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


AD Administrator Syncfusion Team April 26, 2005 02:16 PM

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

Loader.
Live Chat Icon For mobile
Up arrow icon