Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:09:12+00:00 2026-06-03T20:09:12+00:00

I’m having a very strange problem with statuicon. I’m doing on a simple project

  • 0

I’m having a very strange problem with statuicon.

I’m doing on a simple project to save and show some data in table, I have a mainwindow(MainWindow) where the user insert the data and then there is another window where are the data shown(SumList). Also there is a status icon which I have created by sublassing the Gtk.StatusIcon. The problem is that when I start the application and show the window that should show the data(everything works) and then close the window (no matter how) the statusIcon disappear from the panel.

Also I have found that it is cause be the length of constructor of the class SumList. If I delete some lines from there (random order) the statusicon works fine.

How can I fix this strange behavior?

EDIT #1
I try not to subclass the StatusIcon instead i have declared as static member of MainClass and now it works as it should, weird. Anyway the question is why it isn’t working if the statusIcon is not declared static?

The MainClass (StatusIcon)

class MainClass : StatusIcon
{
    MainWindow window;

    private MainClass()
    {
        window = new MainWindow();
        window.Show();

        Stock = Gtk.Stock.Home;

        PopupMenu += rightClick;
        Activate += leftClick;
    }

    private void rightClick (object sender, Gtk.PopupMenuArgs evt){

        window.Hide();
    }

    private void leftClick (object sender, EventArgs e){
        window.Show();

    }


    public static void Main (string[] args)
    {
        Application.Init ();
        new MainClass();

        Application.Run ();
    }
}

The SumList class

public partial class SumList : Gtk.Window
{       
    public SumList () : base(Gtk.WindowType.Toplevel)
    {
        this.Build ();      
        // create the "title" column ------------ //
        TreeViewColumn title = new TreeViewColumn();
        CellRendererText titleR = new CellRendererText();
        title.PackStart(titleR, true);          
        title.AddAttribute(titleR, "text", 0);

        // create the "detial" column ----------- //
        TreeViewColumn detail = new TreeViewColumn();
        CellRendererText detailR = new CellRendererText();
        detail.PackStart(detailR, true);
        detail.AddAttribute(detailR, "text", 1);

        // create the "price" column ------------ //
        TreeViewColumn price = new TreeViewColumn();
        CellRendererText priceR = new CellRendererText();
        price.PackStart(priceR, true);
        price.AddAttribute(priceR, "text", 2);

        // create the "date" column ------------- //
        TreeViewColumn date = new TreeViewColumn();
        CellRendererText dateR = new CellRendererText();
        date.PackStart(dateR, true);
        date.AddAttribute(dateR, "text", 3);

        // set the columns names
        title.Title = "Title";
        detail.Title = "Detail";
        price.Title = "Price";  
        date.Title = "Date";


        // append columns to the treeview       
        this.treeview.AppendColumn(title);
        this.treeview.AppendColumn(detail);
        this.treeview.AppendColumn(price);
        this.treeview.AppendColumn(date);


        // set the model
        this.treeview.Model = Singleton.Model.Instance.Data;    

    }
}

The MainWindow class

public partial class MainWindow: Gtk.Window{    

    public MainWindow (): base (Gtk.WindowType.Toplevel){
        Build ();
    }

    protected void OnDeleteEvent (object sender, DeleteEventArgs a){
        Application.Quit ();
        a.RetVal = true;
    }

    protected void OnButtonOKClicked (object sender, System.EventArgs e){
        SumList list = new SumList();
        list.Show();
    }

    protected void onButtonHideClicked (object sender, System.EventArgs e){
        entrySum.Text = "";
        entryTitle.Text = "";
        this.Hide();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:09:15+00:00Added an answer on June 3, 2026 at 8:09 pm

    Simple, your GTK control is getting garbage collected.

    public static void Main (string[] args)
    {
        Application.Init ();
        new MainClass();
    
        Application.Run ();
    }
    

    You now no longer have any live references to your MainClass instance. IMO you are lucky that the program even does this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.