1
votes

My goal is to query table and add it to ListView. I only get an empty ListView with column names and errors. I used the tutorial, but it doesn't help. I realized that empty rows are added because I can click on them.

        using (MySqlConnection connect = new MySqlConnection(connectionString))
        {
            connect.Open();

            // QUERY GENERATION

            mySqlCommand = new MySqlCommand(query, connect);

            // QUERY PARAMETERS ADDED

            ListStore store = new Gtk.ListStore(typeof(string[]));

            for (int i = 0; i < tempselect.Length; i++) {
                _treeView.AppendColumn(tempselect[i], new Gtk.CellRendererText(), "text");
            }

            MySqlDataReader reader = mySqlCommand.ExecuteReader();

            while (reader.Read())
            {
                store.AppendValues(reader);
            }
            reader.Close();

            _treeView.Model = store;

            connect.Close();
        }

There are no errors. The application just doesn't show data. There are data in the table. I'm trying to fix this for a whole day. Nothing works.

Thank you.

1
I even tried adding one column and one string to the TreeView, the result is the same .... EMPTY !Orvel
I am considering of abandoning CSharp development for Linux. WAY TOO MANY PROBLEMS AND BUGS. I'm still at the beginning of development, its better now than later. When the application gets big, its going to be a bigger problem.Orvel
it's a bug in your code, not in Linux, Mono, or Gtk+jstedfast
Same here. It could be a bug in gtk >= 3.10v1nce

1 Answers

1
votes

I have no idea what tempSelect is based on the code that you pasted...

I would recommend trying this in your loop:

var column = new TreeViewColumn ();
column.Title = "Column Name";
column.Clickable = false;

var renderer = new CellRendererText ();
column.PackStart (renderer, true);

column.AddAttribute (renderer, "text", 0);
_treeView.AppendColumn (column);

I suspect that your problem is that you just need to pass a 0 as your last argument to the AppendColumn() method that you are calling. This value is needed to specify which column the text resides in.