Winforms. How do I allow the user to increase the font size of a list with hidden controls?

I am creating a winform application that will run on a tablet pc. One form for this application will have a listview control.

I would like to allow the user to change the font size based on preference (i.e. they remembered their glasses today). Several ways I can think of are buttons with numeric or top or +/- buttons. Both of these methods require screen real estate, which is very limited.

Is there any control or technique to allow the font to be resized with a hidden one when not in use?

UPDATE 1:

Coming from @GenericTeaType suggestion :

At the class level:

Stopwatch sw = new Stopwatch();

      

In the listview control:

private void lst1_MouseDown(object sender, MouseEventArgs e)
    {
        //start stopwatch
        sw.Reset();
        sw.Start();
    }

private void lst1_MouseUp(object sender, MouseEventArgs e)
    {
        //stop stopwatch
        sw.Stop();
        //how long did stopwatch run for
        TimeSpan elapsedTime = sw.Elapsed;
        //show font change form if time exceeds 3 seconds
            if (elapsedTime.Seconds >= 3)
            {
                //show form - pass in current listview font size
                frmFontSizeChange ffsc = new frmFontSizeChange(slv.ReleaseFontSize);
                ffsc.ShowDialog();

                //refresh schedule with new font size
                populate_lst1();                    
            }
       }

      

+2


a source to share


3 answers


You can just show / hide the control for a specific period of time in the form's MouseClick event.

For instance:

public Form1()
{
    InitializeComponent();
    Timer1.Tick += new EventHandler(Timer1_Tick);
}

Timer Timer1;

private void Form1_MouseClick(object sender, MouseEventArgs e)
{
    // Will need handling to ensure it not already displaying, etc... then:
    FontSizeControl.Show();
    Timer1.Enabled = true;
}

private void FontSizeControl_FontSizeChanged(object sender, EventArgs e)
{

    // Change the font size
    ...

    // Reset the timer
    Timer1.Enabled = false;
    Timer1.Enabled = true;

}

void Timer1_Tick(object sender, EventArgs e)
{
    FontSizeControl.Hide();
    Timer1.Enabled = false;
}

      



This will mostly be shown if you change the FontSize control that you made (or will do) when the user closes the screen. If they then do not touch the control, it will change when checked Timer

. Or it will disappear after the user stops pressing +/- for x milliseconds.

UPDATE to show in 3 seconds.

public Form1()
{
    InitializeComponent();
    Timer2.Tick += new EventHandler(Timer2_Tick);
    Timer2.Interval = 3000;
}

Timer Timer2;

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    Timer2.Enabled = true;
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
    Timer2.Enabled = false;
}

void Timer2_Tick(object sender, EventArgs e)
{
    FontSizeControl.Show();
    Timer2.Enabled = false;
}

      

+2


a source


Well, you can just add a hidden control, but if you're not going to show it, I don't think it makes much sense. Just handle the event KeyPress

either KeyDown

in a form and / or a list, and if it is + or - make it larger or smaller.



Or perhaps it would be safer to use something like Ctrl

+ +

instead of only +

.

+2


a source


I don't know for a tablet, but will FontDialog

not do the job? It is hidden when not in use and you can even create it on the Click button, so resources are not used to make them live, etc.

+1


a source







All Articles