Clearing all controls on "Clear" button

How can I clear all controls when I use the clear button, the text values are not resetting.

You’ll need to clear your controls manually if they are not binded to anything by attaching a clear method to an epi data view notification. There may be other ways to accomplish the same thing tho!

//Method to clear
private void clearCustomUI()
    {
        txtTotalOrderWeight.Clear();
        txtTotalOrderWeight.BackColor = Color.Gray;
        txtTotalGrillWeight.Clear();
        txtTotalGrillWeight.BackColor = Color.Gray;
        txtTotalPelletWeight.Clear();
        txtTotalPelletWeight.BackColor = Color.Gray;
        txtTotalAccWeight.Clear();
        txtTotalAccWeight.BackColor = Color.Gray;
    }

//Event to attach method to
 private void edvOrderHed_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
    {
        // ** Argument Properties and Uses **
        // view.dataView[args.Row]["FieldName"]
        // args.Row, args.Column, args.Sender, args.NotifyType
        // NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
        if ((args.NotifyType == EpiTransaction.NotifyType.AddRow || args.NotifyType == EpiTransaction.NotifyType.DeleteRow || args.NotifyType == EpiTransaction.NotifyType.Initialize))
        {
            if ((args.Row > -1))
            {
                clearCustomUI();
            }
        }
        if (view.dataView.Count == 0)
        {
            clearCustomUI();
        }
    }
txtTotalOrderWeight.Value = 0;
or txtTotalOrderWeight.Text = "";


Also this is not needed:
    if ((args.NotifyType == EpiTransaction.NotifyType.AddRow || args.NotifyType == EpiTransaction.NotifyType.DeleteRow || args.NotifyType == EpiTransaction.NotifyType.Initialize))

Just 
       if (view.dataView.Count < 0)
            clearCustomUI();
1 Like

Thanks for that, in my specific use case I need the
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow || args.NotifyType == EpiTransaction.NotifyType.DeleteRow || args.NotifyType == EpiTransaction.NotifyType.Initialize))

The clear button will not work without that

EDIT: NVM you are right, i dont need that piece but it does need to be <= 0 not just < 0

it’s not clearing with the clear button though, just when a view is presented?

You would need to assign the clearCustomUI(); by adding a tool click event through the wizard.

		case "ClearTool":
			clearCustomUI();
			break;

This should help you: How to clear all controls on a custom sheet - #7 by EpsilonMaximus68Olds

i’ve read that it didn’t help me, but I never knew about the tool click wizard, I am going to try that.

I’d be curious to know why the native clear button isn’t clearing your fields.
Are they bound to something?

no they are not bound, i’m using account budget and have redone it and to search there is no views for it, could of been a dumb way but i’ve already put so much work into it lol

1 Like

This worked! Thank you!

1 Like