winforms

How do I detect if a Windows device is touch-enabled

这一生的挚爱 提交于 2021-02-18 12:13:07
问题 How do I detect if a device is touch-enabled in c# for a WinForms app (Not WPF). I found information on GetSystemMetrics...can't find how to use this in c#. I Tried using System.Windows.Input.Tablet class..not coming up in c#, even though I am using .Net Framework 4.5. I Tried using System.Windows.Devices...not coming up in c#, even though I am using .Net Framework 4.5. I have also checked This and This, which would seem to make this question a duplicate. However, neither of these answers my

Wait until form is finished loading

余生长醉 提交于 2021-02-18 12:00:08
问题 Is there some sort of boolean that I can use to check whether the instance of a form is loaded, or otherwise wait until the form is loaded? for example: While(form_loaded == false) { Try { //do something } catch { }//do try catch so code won't barf } I keep getting the following exception: A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms

Get/Set First Visible Line of RichTextBox

微笑、不失礼 提交于 2021-02-18 10:45:31
问题 I have a RichTextBox with thousands of lines of text in it. I can easily SET the first visible line by using ScrollToCaret() by doing... this.SelectionStart = this.Find(this.Lines[lineIndex], RichTextBoxFinds.NoHighlight); this.ScrollToCaret(); But I would like to be able to GET the first visible line too. Any suggestions? 回答1: Here may be what you need: //get the first visible char index int firstVisibleChar = richTextBox1.GetCharIndexFromPosition(new Point(0,0)); //get the line index from

Multiple slider trackbar for windows forms

佐手、 提交于 2021-02-17 20:28:20
问题 Does anyone have any idea on how to create a trackbar with multiple sliders in WinForms? I would like to mark a range. Also, is it possible to offset the sliders vertically a little bit? My goal would be to have two sliders above the trackbar, and two below it. v-----------------v ________________________________________ ^------^ 回答1: You can do this by writing your own UserControl where you handle the mouse events and painting yourself. You would need several hit test regions; one for each

Multiple slider trackbar for windows forms

偶尔善良 提交于 2021-02-17 20:28:03
问题 Does anyone have any idea on how to create a trackbar with multiple sliders in WinForms? I would like to mark a range. Also, is it possible to offset the sliders vertically a little bit? My goal would be to have two sliders above the trackbar, and two below it. v-----------------v ________________________________________ ^------^ 回答1: You can do this by writing your own UserControl where you handle the mouse events and painting yourself. You would need several hit test regions; one for each

How to change BackColor of all my Panel in my Form

若如初见. 提交于 2021-02-17 07:14:50
问题 I need help with my tool. I have try change Color my Panel with ColorDialog but, it does not work I want change colors all Panel in my Form . Panel constuctor: Panel p = new Panel(); Event handlers: private void button104_Click_1(object sender, EventArgs e) { this.bg.FullOpen = true; if (this.bg.ShowDialog() == DialogResult.OK) { this.setBgColor(this.bg.Color); } } public void setBgColor(Color rgb) { p.BackColor = rgb; } 回答1: You can select all controls of a particular type by using the

Parsing UnregisterHotkey from usercontrol to parent form

家住魔仙堡 提交于 2021-02-17 06:33:31
问题 So I'm attempting to get the userinputs when someone presses hotkeys, also outside the form (in this case SHIFT+A). Now since I wanted to add tabs to my forms application I decided to go with usercontrols, now the problem is, that I am unable to access the formclosing event (from form1) on the usercontrol, meaning I would have to somehow parse whatever I wanted to execute in the formclosing event. Usercontrol (named home) public partial class Home : UserControl { [System.Runtime

Parsing UnregisterHotkey from usercontrol to parent form

こ雲淡風輕ζ 提交于 2021-02-17 06:33:20
问题 So I'm attempting to get the userinputs when someone presses hotkeys, also outside the form (in this case SHIFT+A). Now since I wanted to add tabs to my forms application I decided to go with usercontrols, now the problem is, that I am unable to access the formclosing event (from form1) on the usercontrol, meaning I would have to somehow parse whatever I wanted to execute in the formclosing event. Usercontrol (named home) public partial class Home : UserControl { [System.Runtime

How to use Form.Show(IWin32Window)

倾然丶 夕夏残阳落幕 提交于 2021-02-17 06:21:07
问题 My goal is to use Form as progress bar of the Visio Application during some long actions. Which means, the Form should be display on top of the Visio Application. I also need the Form as non modal dialog (means not Form.ShowDialog() ) in order to letting the Visio app to continue works while the Form is appeares. I've already tried the following steps: Create a wrapper class that implements the IWin32Window. public class WindowWrapper : System.Windows.Forms.IWin32Window { public WindowWrapper

How to use Form.Show(IWin32Window)

*爱你&永不变心* 提交于 2021-02-17 06:21:07
问题 My goal is to use Form as progress bar of the Visio Application during some long actions. Which means, the Form should be display on top of the Visio Application. I also need the Form as non modal dialog (means not Form.ShowDialog() ) in order to letting the Visio app to continue works while the Form is appeares. I've already tried the following steps: Create a wrapper class that implements the IWin32Window. public class WindowWrapper : System.Windows.Forms.IWin32Window { public WindowWrapper