Code Monkey home page Code Monkey logo

Comments (2)

carlokok avatar carlokok commented on July 2, 2024

The second time you set a DataStore it doesn't trigger OnExpanded anymore:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eto;
using Eto.Forms;
using Eto.Drawing;
using System.Threading;

namespace etotest
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            var generator = Generator.GetGenerator("Eto.Platform.Wpf.Generator, Eto.Platform.Wpf");

            var app = new TestApplication(generator);
            app.Run(args);
        }
    }

    public class TestApplication : Application
    {
        public TestApplication(Generator generator)
            : base(generator)
        {
            this.Name = "Test Application";
        }

        public override void OnInitialized(EventArgs e)
        {
            this.MainForm = new MainForm();
            HandleEvent(Application.TerminatingEvent);

            base.OnInitialized(e);

            // show the main form
            this.MainForm.Show();
        }

    }

    public class MainForm : Form
    {
        int[] arr = new int[] { 5, 5 };
        TreeGridView tv;

        void CreateItem(TreeGridItem aParent, string aBaseName, int aLevel)
        {
            var lName = "[" + aLevel + "]" + aBaseName;
            var lItem = new TreeGridItem(lName);
            aParent.Children.Add(lItem);
            if (aLevel < arr.Length)
                for (int i = 0; i < arr[aLevel]; i++)
                    CreateItem(lItem, aBaseName + i.ToString(), aLevel + 1);
        }


        void CreateTree()
        {
            TreeGridItem lRoot = new TreeGridItem();
            CreateItem(lRoot, "Name", 0);

            Application.Instance.Invoke(delegate
            {
                tv.DataStore = lRoot;
                tv.Expanding += Expanding;
            });
        }

        public MainForm()
        {
            Size = new Size(900, 800);
            var lp = new Panel();
            this.AddDockedControl(lp, new Padding(5));
            var lPanelLayout = new TableLayout(lp, 1, 2);
            lPanelLayout.Padding = new Padding(0);
            var lButton = new Button();
            lButton.Text = "Rebuild";
            lButton.Click += but_Click;

            lPanelLayout.Add(lButton, 0, 0);

            tv = new TreeGridView();
            tv.Columns.Add(new GridColumn { DataCell = new TextBoxCell(0) });
            lPanelLayout.Add(tv, 0, 1, true, true);
        }

        void but_Click(object sender, EventArgs e)
        {
            CreateTree();

        }

        void Expanding(object o, EventArgs e)
        {
            MessageBox.Show("Expanding");
        }
    }
}

from eto.

cwensley avatar cwensley commented on July 2, 2024

Fixed with commit 62b60fb

Thanks again for the repro!

from eto.

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.