UIControllerAllowDelete Property

Determines if the user is allowed to use the DeleteRow, Command to delete the current row.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public bool AllowDelete { get; set; }

Property Value

Boolean

Example

using the DeleteRow Command
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
This example uses automatic tools to generate parts of the user interface. Those tools can be found in the example of the documentation of Form
C#
using System.Drawing;
using System.Windows.Forms;
using Firefly.Box;

namespace TestFirefly.Box.Documentation
{
    public class DemoRaiseDelete
    {
        public void RaiseDelete()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var uic = new UIController
            {
                From = jobs,
                View = UITools.GenerateFormWithGridFor("Display Jobs",
                                                       "Click the Delete button to delete the current row",
                                                       jobs.Id,
                                                       jobs.Description,
                                                       jobs.MinLevel,
                                                       jobs.MaxLevel)
            };

            var deleteButton = new Button
            {
                Text = "Delete",
            };
            UITools.AddControlsToForm(uic.View, deleteButton);

            //raise the delete command by the button
            deleteButton.Click += (a, b) => uic.Raise(Command.DeleteRow);
            uic.Run();
        }
        public void HandlingDelete()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var uic = new UIController
            {
                From = jobs,
                View = UITools.GenerateFormWithGridFor("Display Jobs",
                                                       "Click the delete button, and see how the custom handler for the delete command"+
                                                       " takes affect",
                                                       jobs.Id,
                                                       jobs.Description,
                                                       jobs.MinLevel,
                                                       jobs.MaxLevel)
            };

            var deleteButton = new Button
            {
                Text = "Delete",
            };
            UITools.AddControlsToForm(uic.View, deleteButton);

            //raise the delete command by the button
            deleteButton.Click += (a, b) => uic.Raise(Command.DeleteRow);

            uic.Handlers.Add(Command.DeleteRow).Invokes += e =>
            {
                if (MessageBox.Show(
                        "Are you sure you want to delete this row",
                        "Confirm Delete",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                    e.Handled = false;
            };
            uic.Run();
        }
    }
}

See Also