Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Drawing a Family Tree

Drawing a Family Tree

Scheduled Pinned Locked Moved C#
databasegraphicsdata-structuresquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pjholliday
    wrote on last edited by
    #1

    I am trying to draw a Family tree onto a panel by adding several custom panels that contain the data about each person in the tree. I have all the panels displaying but my formula for working out where to place each custom panel is placing them incorrectly. This is my formula. child is the custom panel one generation back in the tree and the index is set according to its vertical position in the generation (i.e the one nearest the top of the panel is 1 and the next lowest 2 and then next lowest 3 etc..) generation is the generation the the animal belongs to (1 being the initial person, 2 being the parents, 3 the grandparens) pw = the custom panel width, hg = the gap between generations, pd = the custom panel height, paneldepth = the main panel height I want the tree to draw left to right. The x co-ordinate works fine its the y co-ordinate that doesnt work, it causes earlier generation to be too close together. // Set Panel Location int x = child.Location.X + pw + hg; int y = ((paneldepth / (generation + 1)) * ((2 * child.Index) - 1)) - (pd / 2); parentpanel.Location = new Point(x, y); Can anyone suggest a formula that might work?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups