0

Is it possible to create a label on a a separate flowlayoutpanel when new data is added to a datagridview? What ihave done is create static labels in the designer and i am able to move them from flowlayoutpanel to flowlayoutpanel.

private void control_MouseDown(object sender, MouseEventArgs e)
{
    var control = sender as Control;
    this.DoDragDrop(control.Name, DragDropEffects.Move);
}

private void panel_DragEnter(object sender, DragEventArgs e)
{
    if (!e.Data.GetDataPresent(typeof(string)))
        return;

    var name = e.Data.GetData(typeof(string)) as string;
    var control = this.Controls.Find(name, true).FirstOrDefault();
    if (control != null)
    {
        e.Effect = DragDropEffects.Move;
    }
}

private void panel_DragDrop(object sender, DragEventArgs e)
{
    if (!e.Data.GetDataPresent(typeof(string)))
        return;

    var name = e.Data.GetData(typeof(string)) as string;
    var control = this.Controls.Find(name, true).FirstOrDefault();
    if (control != null)
    {
        control.Parent.Controls.Remove(control);
        var panel = sender as FlowLayoutPanel;
        ((FlowLayoutPanel)sender).Controls.Add(control);
    }
}
AndroidAL
  • 1,111
  • 4
  • 15
  • 35

1 Answers1

0

I solved this by doing this.

 foreach (DataGridViewRow row in dgv.SelectedRows)
        {
            var Id = row.Cells["ID"].Value.ToString();
            int leadID;

            if (!String.IsNullOrWhiteSpace(Id) && int.TryParse(Id, out ID))
            {
                Label label = new Label();

                label.Text = row.Cells["Name"].Value.ToString();

            }
        }
AndroidAL
  • 1,111
  • 4
  • 15
  • 35