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

Drag&Drop with Custom Visual Item

3 Answers 10 Views
This is a migrated thread and some comments may be shown as answers.
Leandro
Top achievements
Rank 1
Leandro asked on 04 Jul 2019, 03:25 PM

Hey guys, I'm trying to do drag&drop functionality on RadListView, I'm currently using this example and it's works just fine, the only problem is when I'm using custom visual Item on RadListView, there is a little portion of the item where the mouse capture drag&drop, how can make it work for all inside child of my custom visual item? 

    class CartaoCustomVisualListView : SimpleListViewVisualItem
    {
        LightVisualElement tituloElement;
        LightVisualElement dataInicioElement;
        LightVisualElement dataEntregaElement;
        LightVisualElement nomeBancoQueFezASolicitacao;
        LightVisualElement progressoCartaoElement;
        LightVisualElement totalChecklistElement;
        LightVisualElement totalAnexosElement;
        LightVisualElement totalComentariosElement;
        StackLayoutPanel stackLayout;
 
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
            stackLayout = new StackLayoutPanel();
            stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical;
 
            tituloElement = new LightVisualElement();
            tituloElement.Click += (e, f) => this.DoClick(f);
            tituloElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            tituloElement.TextWrap = true;
            tituloElement.Margin = new System.Windows.Forms.Padding(10, 2, 2, 2);
            tituloElement.Font = new System.Drawing.Font("Segoe UI", 10, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
            tituloElement.ForeColor = Color.Black;
            tituloElement.AutoSize = true;
            tituloElement.AutoSizeMode = RadAutoSizeMode.Auto;
            stackLayout.Children.Add(tituloElement);
 
            dataInicioElement = new LightVisualElement();
            dataInicioElement.Click += (e, f) => this.DoClick(f);
            dataInicioElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            dataInicioElement.Margin = new System.Windows.Forms.Padding(10, 2, 0, 2);
            dataInicioElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);
            dataInicioElement.ForeColor = Color.Black;
            dataInicioElement.AutoSize = true;
            dataInicioElement.AutoSizeMode = RadAutoSizeMode.Auto;
            stackLayout.Children.Add(dataInicioElement);
 
            dataEntregaElement = new LightVisualElement();
            dataEntregaElement.Click += (e, f) => this.DoClick(f);
            dataEntregaElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            dataEntregaElement.Margin = new System.Windows.Forms.Padding(10, 2, 0, 2);
            dataEntregaElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);
            dataEntregaElement.ForeColor = Color.Black;
            dataEntregaElement.AutoSize = true;
            dataEntregaElement.AutoSizeMode = RadAutoSizeMode.Auto;
            stackLayout.Children.Add(dataEntregaElement);
 
            nomeBancoQueFezASolicitacao = new LightVisualElement();
            nomeBancoQueFezASolicitacao.Click += (e, f) => this.DoClick(f);
            nomeBancoQueFezASolicitacao.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            nomeBancoQueFezASolicitacao.Margin = new System.Windows.Forms.Padding(10, 2, 0, 2);
            nomeBancoQueFezASolicitacao.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);
            nomeBancoQueFezASolicitacao.ForeColor = Color.Black;
            nomeBancoQueFezASolicitacao.AutoSize = true;
            nomeBancoQueFezASolicitacao.AutoSizeMode = RadAutoSizeMode.Auto;
            stackLayout.Children.Add(nomeBancoQueFezASolicitacao);
 
            progressoCartaoElement = new LightVisualElement();
            progressoCartaoElement.Click += (e, f) => this.DoClick(f);
            progressoCartaoElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            progressoCartaoElement.Margin = new System.Windows.Forms.Padding(10, 2, 0, 2);
            progressoCartaoElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);
            progressoCartaoElement.ForeColor = Color.Black;
            progressoCartaoElement.AutoSize = true;
            progressoCartaoElement.AutoSizeMode = RadAutoSizeMode.Auto;
            stackLayout.Children.Add(progressoCartaoElement);
 
            totalAnexosElement = new LightVisualElement();
            totalAnexosElement.Click += (e, f) => this.DoClick(f);
            totalAnexosElement.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
            totalAnexosElement.Margin = new System.Windows.Forms.Padding(10, 1, 10, 1);
            totalAnexosElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
            totalAnexosElement.ForeColor = SystemColors.AppWorkspace;
            totalAnexosElement.AutoSize = true;
            totalAnexosElement.AutoSizeMode = RadAutoSizeMode.Auto;
            totalAnexosElement.DrawText = true;
            stackLayout.Children.Add(totalAnexosElement);
 
            totalChecklistElement = new LightVisualElement();
            totalChecklistElement.Click += (e, f) => this.DoClick(f);
            totalChecklistElement.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
            totalChecklistElement.Margin = new System.Windows.Forms.Padding(10, 1, 10, 1);
            totalChecklistElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
            totalChecklistElement.ForeColor = SystemColors.AppWorkspace;
            totalChecklistElement.AutoSize = true;
            totalChecklistElement.AutoSizeMode = RadAutoSizeMode.Auto;
            totalChecklistElement.DrawText = true;
            stackLayout.Children.Add(totalChecklistElement);
 
            totalComentariosElement = new LightVisualElement();
            totalComentariosElement.Click += (e, f) => this.DoClick(f);
            totalComentariosElement.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
            totalComentariosElement.Margin = new System.Windows.Forms.Padding(10, 1, 10, 1);
            totalComentariosElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
            totalComentariosElement.ForeColor = SystemColors.AppWorkspace;
            totalComentariosElement.AutoSize = true;
            totalComentariosElement.AutoSizeMode = RadAutoSizeMode.Auto;
            totalComentariosElement.DrawText = true;
            stackLayout.Children.Add(totalComentariosElement);
 
             
            Children.Add(stackLayout);
            Shape = new RoundRectShape(5);
            this.BackColor = Color.White;
            this.Padding = new Padding(5);
        }
 
        protected override void SynchronizeProperties()
        {
            var bound = this.Data.DataBoundItem as cartao_model;
            if(bound != null)
            {
                tituloElement.Text = bound.obj_cartao.titulo;
                if (bound.obj_cartao.data_inicio != null)
                {
                    dataInicioElement.Text = "Data inicio: " + bound.obj_cartao.data_inicio.ToString();
                    dataInicioElement.Visibility = ElementVisibility.Visible;
                }
                else
                    dataInicioElement.Visibility = ElementVisibility.Collapsed;
                if (bound.obj_cartao.data_entrega != null)
                {
                    dataEntregaElement.Text = "Data entrega: " + bound.obj_cartao.data_entrega.ToString();
                    dataEntregaElement.Visibility = ElementVisibility.Visible;
                }
                else
                    dataEntregaElement.Visibility = ElementVisibility.Collapsed;
 
                if (bound.obj_cartao.id_banco_de_dados != null && bound.obj_cartao.id_banco_de_dados != 0)
                {
                    nomeBancoQueFezASolicitacao.Text = "Solicitador por: " + bound.obj_cartao.banco_de_dados.nome;
                    nomeBancoQueFezASolicitacao.Visibility = ElementVisibility.Visible;
                }
                else
                    nomeBancoQueFezASolicitacao.Visibility = ElementVisibility.Collapsed;
 
                if (bound.anexos.TemRegistro())
                {
                    totalAnexosElement.Visibility = ElementVisibility.Visible;
                    totalAnexosElement.Text = $"anexos: {bound.anexos.Count()}";
                }
                else
                    totalAnexosElement.Visibility = ElementVisibility.Collapsed;
 
                int totalConcluidos = 0, totalItens = 0;
                if (bound.obj_cartao.checklist.TemRegistro())
                {
                    totalChecklistElement.Visibility = ElementVisibility.Visible;
                    foreach(var item in bound.obj_cartao.checklist)
                    {
                        totalConcluidos = totalConcluidos + item.itens.Where(c => c.concluido == true).Count();
                        totalItens = totalItens + item.itens.Count();
                        if(totalItens == totalConcluidos)
                        {
                            totalChecklistElement.ForeColor = Color.Green;
                            totalChecklistElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
                        }
                        else
                        {
                            totalChecklistElement.ForeColor = SystemColors.AppWorkspace;
                            totalChecklistElement.Font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold, GraphicsUnit.Point);
                        }                       
                    }
                    totalChecklistElement.Text = $"checklist: {totalConcluidos}/{totalItens}";
                }
                else
                    totalChecklistElement.Visibility = ElementVisibility.Collapsed;
                 
 
                if (bound.comentarios.TemRegistro())
                {
                    totalComentariosElement.Visibility = ElementVisibility.Visible;
                    totalComentariosElement.Text = $"coment├írios: {bound.comentarios.Count()}";
                }
                else
                    totalComentariosElement.Visibility = ElementVisibility.Collapsed;
                 
 
                progressoCartaoElement.Text ="Status: " + bound.obj_cartao.progresso_cartao.GetDescription();
            }
             
             
        }
 
    }
 
 

3 Answers, 1 is accepted

Sort by
0
Leandro
Top achievements
Rank 1
answered on 04 Jul 2019, 03:26 PM
the link is https://docs.telerik.com/devtools/winforms/controls/listview/drag-and-drop/drag-and-drop-in-bound-mode
0
Nadya
Telerik team
answered on 05 Jul 2019, 01:10 PM
Hello Leandro,

You should set the NotifyParentOnMouseInput property to true, and the ShouldHandleMouseInput property to false to all of the elements in the CreateChildElements method as shown below:
stackLayout.NotifyParentOnMouseInput = true;
stackLayout.ShouldHandleMouseInput = false;
 
tituloElement.NotifyParentOnMouseInput = true;
tituloElement.ShouldHandleMouseInput = false;
 
//TO DO the rest of the elements

I hope this helps. Should you have any other questions, I will be glad to help.

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Leandro
Top achievements
Rank 1
answered on 05 Jul 2019, 02:52 PM
thanks, it worked!
Asked by
Leandro
Top achievements
Rank 1
Answers by
Leandro
Top achievements
Rank 1
Nadya
Telerik team
Share this question
or