This is a migrated thread and some comments may be shown as answers.

How do you Add Mouse Events to Child Grid in CodeBehind

0 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 15 Nov 2011, 04:16 PM
So, I figured out how to create the Child grid int he code behind, but now I need to have a click event on the Child grid rows. With the following code I get a "Handler type is mismatched" on the order.AddHandler line.

Any help on how to get this to work?

Thanks,

Doug

    private void rgvPatientImages_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
    {
        GridViewDataControl dataControl = (GridViewDataControl)sender;
 
        if (dataControl.ParentRow != null)
        {
            dataControl.BorderThickness = new Thickness(0, 1, 0, 1);
            dataControl.GridLinesVisibility = GridLinesVisibility.None;
            dataControl.CanUserFreezeColumns = false;
            dataControl.ShowGroupPanel = false;
            dataControl.AutoGenerateColumns = false;
            dataControl.ChildTableDefinitions.Clear();
            dataControl.IsReadOnly = true;
            dataControl.SelectionMode = SelectionMode.Single;
            dataControl.SelectionUnit = GridViewSelectionUnit.Cell;
 
            GridViewDataColumn customerId = new GridViewDataColumn();
            customerId.Header = "Customer Id";
            customerId.DataMemberBinding = new Binding("CustId");
            customerId.DataType = typeof(int);
            dataControl.Columns.Add(customerId);
 
            GridViewDataColumn order = new GridViewDataColumn();
            order.UniqueName = "OrderIdId";
            order.Header = "Order Id";
            order.DataType = typeof(int);
 
            order.AddHandler(MouseLeftButtonDownEvent, new EventHandler<MouseButtonEventArgs> (orderId_MouseLeftButtonUp));
            dataControl.Columns.Add(order);
     }
}
 
    private void orderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        object ID = ((Button)sender).CommandParameter;
 
        CustomerOrder NewWindow = new CustomerOrder();
        NewWindow.orderId = Convert.ToInt32(sender.ToString());
        NewWindow.Show();
        this.Close();
    }

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Doug
Top achievements
Rank 1
Share this question
or