Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

AutoComplete1 Sample (C#)

This sample illustrates autocomplete.

This is not an executable sample, so a complete project is not provided. These statements are intended to show basic concepts and the syntax used.

private void Form1_Load(object sender, System.EventArgs e)
{
    SftMaskAutoComplete AutoCompleteObj;
    SftMaskCaption CaptionObj;

    CaptionObj = axSftMask1.Caption;
    AutoCompleteObj = axSftMask1.AutoComplete;

    CaptionObj.SizePercent = 33;
    CaptionObj.Text = "&ZIP Code:";

    axSftMask1.Mask = "#####";
    axSftMask1.EntrySelect = SftMaskEntrySelectConstants.entrySftMaskSelectEndHome;

    AutoCompleteObj.File = @"-\Softelvdm\AutoComplete\SampleFile2.Suggest";
    AutoCompleteObj.Encrypt = false;
    AutoCompleteObj.IgnoreCase = true;
    AutoCompleteObj.MaxEntries = 50;
    AutoCompleteObj.Mode = SftMaskAutoCompleteModeConstants.autocompleteSftMaskSuggest;
}

private void axSftMask1_MatchAddCustomItems(object sender, AxSftMaskLib70._ISftMaskEvents_MatchAddCustomItemsEvent e)
{
    // Ready to add custom items
    axSftMask1.AutoComplete.AddTop("ZIP-Code Lookup ...", 1);
    axSftMask1.AutoComplete.AddTop("State Lookup ...", 2);
    if (e.count > 6) {
        axSftMask1.AutoComplete.AddBottom("ZIP-Code Lookup ...", 2);
        axSftMask1.AutoComplete.AddBottom("State Lookup ...", 2);
    }
}

private void axSftMask1_MatchCustom(object sender, AxSftMaskLib70._ISftMaskEvents_MatchCustomEvent e)
{
    if (e.entryType == 1) {
        axSftMask1.Rollup();
        MessageBox.Show("We could be looking up ZIP codes in another application...");
        axSftMask1.Text = "12345";
    }
    if (e.entryType == 2) {
        axSftMask1.Rollup();
        MessageBox.Show("We could be looking up states in another application...");
        axSftMask1.AutoComplete.Refresh();
    }
}

private void axSftMask1_Matching(object sender, AxSftMaskLib70._ISftMaskEvents_MatchingEvent e)
{
    if (e.entryText[0] == '0') {
        // don't show any ZIP code starting with a "0"
        e.accept = false;
    }
}

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.