Profile Picture

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

Posted By Miles Thornton 14 Years Ago

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

Author
Message
Miles Thornton
questionmark Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
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!



Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

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
Last Active: Last Month
Posts: 139, Visits: 184

Hello Miles,

Regarding your first question you need to call Select method in the Enter event hander:

private void nNumericUpDown1_Enter(object sender, EventArgs e)

{

    int length = nNumericUpDown1.Text.Length;

    nNumericUpDown1.Select(0, length);

}

If you also want to select the entire value when the user clicks with the mouse over the control you have to call Select method the same way in MouseClick event handler too.

In your second question is not getting clear which control do you mean. Can you specify the control that you asking for?

Thanks and regards,

Angel.

 



Miles Thornton
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
Posts: 17, Visits: 1

Angel,

Thank you very much for the help! Your suggestion for my question #1 was SPOT ON! I have a number of NNumericUpDown components, so:

private void nnud_Enter(object sender, EventArgs e)

{

int length = ((Nevron.UI.WinForm.Controls.NNumericUpDown)sender).Text.Length;

((Nevron.UI.WinForm.Controls.NNumericUpDown)sender).Select(0, length);

}

As for my question #2...

Suppose I have a NComboBox with 1000 pre-populated Items. I would like to have the control pare-down the list of available choices as the user types into the .Text property...

IE: Unfiltered list contains 1000 elements; user types into the text property, the control limits (hides) elements that do not match what the user types:

So, the Items list has 100 elements starting with "CFL ..."

50 elements starting with "CFLL"

10 elements starting with "CFLL-01"

The user has pared-down his 1000 choices to a mere 10 by typing 7 characters; see the advantage?

I suppose that I could catch the TextChanged event and iterate the list comparing the first <Text.Length> characters of each NListBoxItemText to the users input to toggle each NListBoxItem.Visible - If such a property existed...

Anyway; that's the functionality I need. I realize now that I could do this with multiple in-memory NListBoxItem[] - To restore the list, etc...

I hope that this post is much more clear about what I was talking about - I do apologize for being unclear!

Thanks again,

-Miles

 



Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

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
Last Active: Last Month
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.

 



Miles Thornton
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
Posts: 17, Visits: 1

That did the trick - Thank You Angel!

Btw, Angel - Since I am loading lists from XML files; I'd like the form's this.UseWaitCursor = true; to work - but it doesn't... Can you tell me why and more importantly, what to do?

Thanks



Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

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
Last Active: Last Month
Posts: 139, Visits: 184

Hi Miles,

I've read that this property doesn't work correctly for some reason.

Please try to set the cursor by changing the value of Cursor property:

Cursor = Cursors.WaitCursor;

...

Cursor = Cursors.Default;

Regards,

Angel.



Miles Thornton
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
Posts: 17, Visits: 1

Thanks again Angel!

Cursor = Cursors.WaitCursor;

...

Cursor = Cursors.Default;

WORKS!





Similar Topics


Reading This Topic