Giter Site home page Giter Site logo

Comments (6)

Roemer avatar Roemer commented on May 18, 2024

Same goes for Menu/menuitems I guess. Will have a look at this.

from flaui.

Roemer avatar Roemer commented on May 18, 2024

How about a virtual FindByText method on the combobox?
The default implementation would loop thru the Items and select their .Name and returns the first which matches the text or null otherwise.
So it would look like:

myCombo.FindByText("Some Value")?.Select();

from flaui.

Roemer avatar Roemer commented on May 18, 2024

Pretty much like this:

/// <summary>
/// Search the first item which matches the given text.
/// </summary>
/// <param name="textToFind">The text to search for.</param>
/// <returns>The first found item or null if no item matches.</returns>
public virtual ComboBoxItem FindByText(string textToFind)
{
    var items = Items;
    return items.FirstOrDefault(item => item.Text.Equals(textToFind));
}

Would that be enough?

from flaui.

jochenparm avatar jochenparm commented on May 18, 2024

Sure, functionally this would work, but now the API for selecting an item is different depending on whether you want to select by id or by text.
myCombo.Items[int index].Select();
myCombo.FindByText("Some Value")?.Select();

while I would find the following more logical (but it is a breaking API change...):
myCombo.Items.Select(int index);
myCombo.Items.Select(string textToFind);

from flaui.

Roemer avatar Roemer commented on May 18, 2024

Check my commit above ;) It's exactly like this now. Except that it is myCombo.Select(int index or string textToFind) and not myCombo.Items.Select(...)

from flaui.

jochenparm avatar jochenparm commented on May 18, 2024

Great, that's even better IMO! (and nicely matches the White API ;) )

from flaui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.