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

  • Home
  • SEARCH
  • 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 661425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:15:56+00:00 2026-05-13T23:15:56+00:00

I would like to display a directory structure using Gtk# widgets through F#, but

  • 0

I would like to display a directory structure using Gtk# widgets through F#, but I’m having a hard time figuring out how to translate TreeViews into F#. Say I had a directory structure that looks like this:

Directory1
  SubDirectory1
  SubDirectory2
    SubSubDirectory1
  SubDirectory3
Directory2

How would I show this tree structure with Gtk# widgets using F#?

EDIT:

gradbot’s was the answer I was hoping for with a couple of exceptions. If you use ListStore, you loose the ability to expand levels, if you instead use :

let musicListStore = new Gtk.TreeStore([|typeof<String>; typeof<String>|])

you get a layout with expandable levels. Doing this, however, breaks the calls to AppendValues so you have to add some clues for the compiler to figure out which overloaded method to use:

musicListStore.AppendValues (iter, [|"Fannypack" ; "Nu Nu (Yeah Yeah) (double j and haze radio edit)"|])

Note that the columns are explicitly passed as an array.

Finally, you can nest levels even further by using the ListIter returned by Append Values

let iter = musicListStore.AppendValues ("Dance")
let subiter = musicListStore.AppendValues (iter, [|"Fannypack" ; "Nu Nu (Yeah Yeah) (double j and haze radio edit)"|])
musicListStore.AppendValues (subiter, [|"Some Dude"; "Some Song"|]) |> ignore
  • 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-05-13T23:15:56+00:00Added an answer on May 13, 2026 at 11:15 pm

    I’m not exactly sure what you’re looking for but here is a translated example from their tutorials. It may help you get started. Image taken from tutorial site.

    alt text
    I think the key to a multi-level tree view is to append values to values, iter in this line musicListStore.AppendValues (iter, "Fannypack", "Nu Nu (Yeah Yeah) (double j and haze radio edit)") |> ignore

    // you will need to add these references gtk-sharp, gtk-sharp, glib-sharp 
    // and set the projects running directory to 
    // C:\Program Files (x86)\GtkSharp\2.12\bin\
    
    module SOQuestion
    
    open Gtk
    open System
    
    let main() =
        Gtk.Application.Init()
    
        // Create a Window
        let window = new Gtk.Window("TreeView Example")
        window.SetSizeRequest(500, 200)
    
        // Create our TreeView
        let tree = new Gtk.TreeView()
        // Add our tree to the window
        window.Add(tree)
    
        // Create a column for the artist name
        let artistColumn = new Gtk.TreeViewColumn()
        artistColumn.Title <- "Artist"
    
        // Create the text cell that will display the artist name
        let artistNameCell = new Gtk.CellRendererText()
        // Add the cell to the column
        artistColumn.PackStart(artistNameCell, true)
    
        // Create a column for the song title
        let songColumn = new Gtk.TreeViewColumn()
        songColumn.Title <- "Song Title"
    
        // Do the same for the song title column
        let songTitleCell = new Gtk.CellRendererText()
        songColumn.PackStart(songTitleCell, true)
    
        // Add the columns to the TreeView
        tree.AppendColumn(artistColumn) |> ignore
        tree.AppendColumn(songColumn) |> ignore
    
        // Tell the Cell Renderers which items in the model to display
        artistColumn.AddAttribute(artistNameCell, "text", 0)
        songColumn.AddAttribute(songTitleCell, "text", 1)
    
        let musicListStore = new Gtk.ListStore([|typeof<String>; typeof<String>|])
    
        let iter = musicListStore.AppendValues ("Dance")
        musicListStore.AppendValues (iter, "Fannypack", "Nu Nu (Yeah Yeah) (double j and haze radio edit)") |> ignore
    
        let iter = musicListStore.AppendValues ("Hip-hop")
        musicListStore.AppendValues (iter, "Nelly", "Country Grammer") |> ignore
    
        // Assign the model to the TreeView
        tree.Model <- musicListStore
    
        // Show the window and everything on it
        window.ShowAll()
    
        // add event handler so Gtk will exit
        window.DeleteEvent.Add(fun _ -> Gtk.Application.Quit())
    
        Gtk.Application.Run()
    
    [<STAThread>]
    main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing an app that I would like to display different views based on
Okay, I have a TreeView that serves as a directory tree for Windows. I
Without having a url rewriter such as ISAPI_Rewrite available, is it possible to achieve
I am using MVC 2. I have 2 controllers called Application and Note. The
I am looking to achieve the following: Display 5 images in a row Click
This answer to what looks like the same question: Convert integer to hex and
So here's my project: I am building a central interface/dashboard to present the test
Somewhat related to How to convert XML to java.util.Map and vice versa , only
Overview: I am looking to create a site that will centralize a lot of
I run a small blog network and on this I have a page where

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.