Auto-Select Value in Nevron.UI.WinForm.Controls.NNumericUpDown on Enter?


Auto-Select Value in Nevron.UI.WinForm.Controls.NNumericUpDown on...
Author
Message
Miles Thornton
Miles Thornton
Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)
Group: Forum Members
Posts: 17, Visits: 1

I have a data-entry Winforms app exclusively using the Nevron.UI.WinForm.Controls.  However, there are a couple of things I need to ask about...

Is there an existing way to:

1. Auto-Select the entire Value in Nevron.UI.WinForm.Controls, specifically a NNumericUpDown, during the OnEnter event? This would allow the user to simply key the new value without having to manually delete the existing value - saving keystrokes and time...

2. Filter a CheckListBox.Items collection as the user Types into the display field? I have rather large picklists and the Filter-as-you-type feature would really help me out...

Thank You!


Reply
Angel Chorbadzhiev
Angel Chorbadzhiev
Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)
Group: Forum Members
Posts: 139, Visits: 184

Hi Miles,

We do not have this functionality build-in, but you can easily implement it.

Here is one example implementation.

Create 2 fields - one will hold all items and second will hold the items that should be displayed:

object[] m_List;

List<object> m_TempList;

In the constructor you can initialize both fields and set the m_List with all items in the combo box:

int count = nComboBox1.Items.Count;

m_List = new object[count];

m_TempList = new List<object>();

for (int i = 0; i < count; i++)

{

    NListBoxItem item = nComboBox1.Items[i];

    m_List[i] = item;

}

Attach to the NComboBox.EditControl.KeyUp event and in the event handler check whether the current text is contained in the items. Then add these items in the m_TempList, and set the combo items to m_TempList:

nComboBox1.EditControl.KeyUp += new KeyEventHandler(EditControl_Up);

...

void EditControl_Up(object sender, KeyEventArgs e)

{

    int count = m_List.Length;

    m_TempList.Clear();

    for (int i = 0; i < count; i++)

    {

        NListBoxItem item = (NListBoxItem)m_List[i];

        if (item.Text.Contains(nComboBox1.Text))

        {

            m_TempList.Add(item);

        }

    }

    nComboBox1.Items.Clear();

    nComboBox1.Items.AddRange(m_TempList.ToArray());

}

Finally, attach to NComboBox.EditItem.Leave event and put back all items saved in m_List:

nComboBox1.EditControl.Leave += new EventHandler(EditControl_Leave);

...

void EditControl_Leave(object sender, EventArgs e)

{

    nComboBox1.Items.Clear();

    for (int i = 0; i < m_List.Length; i++)

    {

        nComboBox1.Items.Add(m_List[i]);

    }

}

 

I hope this example will help.

Regards,

Angel.

 


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search