windows-forms-designer

Event for Click in any button (C# windows forms)

最后都变了- 提交于 2019-11-28 08:43:53
问题 I'm developing a program that has many buttons that should do a similar action when clicked, but with a small difference based on which button was clicked. The problem is that the only straightforward path is to code this for each button, which would be a very repetitive task. Is there a way to program simply one block that would get the click on any button and which button was clicked? 回答1: Assign the same event handler to all buttons. foreach (var button in Controls.OfType<Button>()) {

Disable designer in Visual Studio?

落花浮王杯 提交于 2019-11-28 07:13:40
I'm using Visual C# Express to write Windows Form applications, and call me old school, but I don't like the designer. It is a nuisance and pollutes my project with lots of unwanted files, as well as unwanted monkey-generated source code. Please tell me there's a way to turn it off completely. Just dont add "new form" , add to the project new class and inherit him from the Form class. Add a [System.ComponentModel.DesignerCategory("")] attribute before a UI class to avoid designer activation on double-click. Note that including System.ComponentModel at the top of the file and then just adding

Baseline snaplines in custom Winforms controls

試著忘記壹切 提交于 2019-11-28 05:18:32
I have a custom user control with a textbox on it and I'd like to expose the baseline (of the text in the textbox) snapline outside of the custom control. I know that you create a designer (inherited from ControlDesigner) and override SnapLines to get access to the snaplines, but I'm wondering how to get the text baseline of a control that I have exposed by my custom user control. I just had a similar need, and I solved it like this: public override IList SnapLines { get { IList snapLines = base.SnapLines; MyControl control = Control as MyControl; if (control == null) { return snapLines; }

Allowing javascript to run on a windows form web browser

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:02:24
I want to use a Web Browser to access a website that uses JavaScript on load. I understand that Web Browser is a wrapper of the current installed version of Internet Explorer. However, testing the website on Internet Explorer yields no errors but does not work if I use the Web Browser to access the content. I have also looked at my internet security settings to ensure it is enabled. The issue I get is; Awkwardly enough, I found the answer moments after posting this but I thought anyone who comes across the same problem as me will find solace in this answer; It seems downloading the latest

Why does C# designer-generated code (like Form1.designer.cs) play havoc with Subversion?

落花浮王杯 提交于 2019-11-28 04:34:42
My workshop has recently switched to Subversion from SourceSafe, freeing us from automatic locks. This led to concurrent editing of the Forms, which is wonderful. But when multiple developers commit their changes, the code files created by the designer (all the files named TheFormName.designer.cs ) cause conflicts which are very difficult to resolve. As far as I can tell, this is because the code generated by the designer is heavily re-arranged whenever the user modifies it, no matter how little the actual change really did. How do I make these conflicts easier to resolve? Is there some way to

How can I hide the resizing handles of a control in Windows Forms?

佐手、 提交于 2019-11-28 04:17:00
问题 I have an UserControl and would like to hide the resizing handles in design-time, just like the TextBoxControl, that has only two handles (left and right ones)... the height of the textbox is fixed, unless you say it is multiline. In that case, the textbox shows all nine resizing handles. 回答1: You need to implement a custom designer (ControlDesigner) for your control and then override the SelectionRules property. Useful reference: Extending Design-Time Support 回答2: I think you would need to

UserControl with header and content - Allow dropping controls in content panel and Prevent dropping controls in header at design time

点点圈 提交于 2019-11-28 01:32:47
I wrote User Control (yay!). But I want it to behave as a container. But wait! I know about [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] Trick. The problem is - I don't want all of my control to behave like container, but only one part. One - de facto - panel ;) To give wider context: I wrote a control that has Grid, some common buttons, labels and functionalities. But it also has a part where the user is supposed to drop his custom buttons/controls whatever. Only in this particular part of the control, nowhere else. Anyone had any idea? You

Click event for .Net (Windows Forms) user control

会有一股神秘感。 提交于 2019-11-28 01:20:54
This is probably a very simple question, but for some reason, even the right way to web search for the answer eludes me... I'm trying to create a user control that consists of a few labels and progress bars. However, I want the entire control to have a "Click" event that is raised no matter what item inside the control is clicked on. I've created a "HandleClick" procedure that is assigned to each control: private void HandleClick(object sender, EventArgs e) { // Call the callback function, if we were asked to if (OnClick != null) { EventArgs ee = new EventArgs(); OnClick(this, ee); } else {

Running a .exe application from Windows Forms

帅比萌擦擦* 提交于 2019-11-28 00:28:03
问题 I have an application that I run on the command prompt as follows: C:\some_location> "myapplication.exe" headerfile.h I want to create a Windows Forms application where the user can specify the location of the executable and also the header file so that the Windows Forms application can do this for him/her, and the user wouldn't have to go to the command line and do it. How can I do this? 回答1: You need to use the Process class: Process.Start(@"C:\some_location\myapplication.exe"); For

How To Convert A Number To an ASCII Character?

不羁岁月 提交于 2019-11-27 23:26:37
问题 I want to create an application where user would input a number and the program will throw back a character to the user. Edit: How about vice versa, changing a ascii character into number? 回答1: You can use one of these methods to convert number to an ASCII / Unicode / UTF-16 character: You can use these methods convert the value of the specified 32-bit signed integer to its Unicode character: char c = (char)65; char c = Convert.ToChar(65); Also, ASCII.GetString decodes a range of bytes from a