dotnet/winforms

Proposal: add SelectionStart and SelectionEnd to TrackBar

Open

#2,642 建立於 2020年1月6日

在 GitHub 查看
 (10 留言) (2 反應) (2 負責人)C# (922 fork)batch import
api-approveddesign-discussionhelp wantedtenet-compatibility-OS

倉庫指標

Star
 (4,100 star)
PR 合併指標
 (平均合併 14天 22小時) (30 天內合併 56 個 PR)

描述

You can set the TBS_ENABLESELRANGE on TrackBar and send the TBM_SETSELSTART and TBM_SETSELSTART to set the selection range See docs

Example: Screenshot 2020-01-06 at 16 31 38 Screen Recording 2020-01-06 at 04 32 pm

We could add the following APIs to TrackBar:

public class TrackBar
{
    ...
    public bool ShowSelectionRange { get; set; }
    public int SelectionStart { get; set; }
    public int SelectionEnd { get; set; }
    ...
}

Discussion

  • What should the default values of SelectionStart and SelectionEnd be if we haven't enabled selections? In my experiments I set them to 0 which worked nicely.
  • In my prototype implementation, I set ShowSelectionRange to true if the user sets SelectionStart/SelectionEnd. One option could be to remove ShowSelectionRange and set SelectionStart/SelectionEnd to minus one or have some logic that sets the TrackBar style to TBS_ENABLESELRANGE if it is set to a custom value. However, this is negative as it leaves us with no way of removing the selection indicators once they've been created.
  • Do we want SelectionStart and SelectionEnd or SelectionStart and SelectionLength or some sort of SelectionRange struct that encapsulates this? (e.g MonthCalendar.SelectionRange)

貢獻者指南