0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Gtk3アプリGtk.ListStoreを使ってコントロールを更新する

Last updated at Posted at 2021-11-24

###Gtk3アプリGtk.ListStoreを使ってコントロールを更新する

Gtk.ListStoreを使いコントロールの更新を行います。
不特定の関数を作るのではなく、ListStoreのイベントハンドリングでまとめて更新をするとわかりやすくなります。

Screenshot from 2021-11-24 14-34-48.png
private Gtk.ListStore listStore1 = new Gtk.ListStore (typeof (testModel));

private void on_btn1_clicked(object sender , EventArgs e){

    testModel testModel1 = new testModel();
    testModel1.Name = "タイトル1";
    testModel1.Description = "詳細1";
    listStore1.Clear();
    listStore1.AppendValues (testModel1);
		
}

private void _mkBining()
{
    listStore1.RowChanged += delegate(object o, RowChangedArgs args)
    {
        ListStore testStore = ((ListStore)o);
        TreeIter iter;
        if (testStore.GetIter(out iter, args.Path))
        {
            testModel testModel1 = (testModel)testStore.GetValue(iter, 0);
            Console.WriteLine("testModel1" + testModel1.icon_id  );
            titleEntry.Text = testModel1.Name;
            descriptionEntry.Text = testModel1.Description;
        }
    };
}

ListStoreのRowChangedメソッドを使い、ListStoreが更新されたら他のコントロールを更新するようにします。

listStore1.RowChanged += delegate(object o, RowChangedArgs args)
{
	ListStore testStore = ((ListStore)o);
	TreeIter iter;
	if (testStore.GetIter(out iter, args.Path))
	{
 	   testModel testModel1 = (testModel)testStore.GetValue(iter, 0);
	}
};

Gtk3アプリ RiderとMySqlとDapperに続く

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?