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. Hour and minute slider

Hour and minute slider

Scheduled Pinned Locked Moved C#
csharpjavascriptdesigntutorialquestion
3 Posts 3 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.
  • V Offline
    V Offline
    Valakik
    wrote on last edited by
    #1

    Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.

    OriginalGriffO B 2 Replies Last reply
    0
    • V Valakik

      Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Create a UserControl, and start there. Give it a fixed height, and add four "points": minimum, maximum, low, high. These are probably integer values which do not relate in any way directly to hours and minutes, so the control can be flexible. Handle the Paint event to draw the control and two "handles" that you can move. Handle the MouseDown, MouseUp, and MouseMove events to let you move the handles. As they move, update the low and high values. Provide properties to read the values, and in there translate the integers to hours and minutes - perhaps return a timespan? One digit move could be your fifteen minutes. Provide an event to indicate "slider changed" so the outside world can react to it.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • V Valakik

        Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.

        B Offline
        B Offline
        BillWoodruff
        wrote on last edited by
        #3

        put two System.Windows.Forms.TrackBar Controls on a form: tBarHour, tBarMinute. Configure:

        // tBarHour
        //
        this.tBarHour.LargeChange = 4;
        this.tBarHour.Location = new System.Drawing.Point(280, 148);
        this.tBarHour.Maximum = 23;
        this.tBarHour.Name = "tBarHour";
        this.tBarHour.Size = new System.Drawing.Size(375, 45);
        this.tBarHour.TabIndex = 11;
        this.tBarHour.Value = 12;
        this.tBarHour.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged);
        //
        // tBarMinute
        //
        this.tBarMinute.LargeChange = 10;
        this.tBarMinute.Location = new System.Drawing.Point(280, 200);
        this.tBarMinute.Maximum = 59;
        this.tBarMinute.Name = "tBarMinute";
        this.tBarMinute.Size = new System.Drawing.Size(375, 45);
        this.tBarMinute.TabIndex = 12;
        this.tBarMinute.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged);

        The Minimum TrackBar value is #0 by default. Set the ValueChanged event handler for both TrackBars to:

        private TimeSpan tSpan;

        private string tSpanStr;

        private void tBarHourMinute_ValueChanged(object sender, EventArgs e)
        {
        tSpan = new TimeSpan(0, tBarHour.Value, tBarMinute.Value, 0);

        tSpanStr = tSpan.ToString());
        

        }

        «One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali

        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