windows-forms-designer

Multi Threading C# Windows Forms

我怕爱的太早我们不能终老 提交于 2019-12-25 17:46:15
问题 So I am trying to implement multi-threading in my windows forms project. I know of one way to do this, by creating a new thread for the methods you want to run separately like this: Thread t = new Thread(new ThreadStart(methodName)); t.Start(); And then invoking each object that is "Accessed from a thread other than the thread it was created on." like this: this.Invoke(new MethodInvoker(delegate() { this.Object = "whatever"; })); The only problem with this is, my program is several thousand

How to get form when it is which is not visible?

╄→гoц情女王★ 提交于 2019-12-25 16:57:12
问题 I want to get form which is open but hidden. I have tried by this. I get the form but in this case form show and hide within fraction of second. If I skip mfrm.Show() , I don't get MailSynchronize form in Application.OpenForms . MailSynchronize mfrm = new MailSynchronize(); mfrm.Show(); mfrm.Hide(); I get form by following method. foreach (Form f in Application.OpenForms) //it will return all the open forms { if (f.Name == "MailSynchronize") { mfrm = (MailSynchronize)f; break; } } Can anybody

Windows Forms - How to return WMIC output into Textbox

僤鯓⒐⒋嵵緔 提交于 2019-12-25 14:22:37
问题 I'm new to coding ( 3 days in and learning primarily from Google ) it's going well enough so far but now I'm stuck :) I want to run a WMIC command and return the second line of the output into a textbox. The WMIC command is: 'WMIC bios get serialnumber' This returns: SerialNumber ABCD1234 How do I get just the serial number into a textbox please? Thanks... 回答1: Add reference to System.Management and use the following in your form method. ManagementObjectSearcher searcher = new

Best way to pass data to a DataGridView form from another non-form class

纵饮孤独 提交于 2019-12-25 08:47:50
问题 As the title says, I need to pass a list of hashtables from a regular class to a form class to be rendered in a DataGridView. What I've got so far is this: namespace somenamespace { class aldeloUpdater { private static string client = "chanchitos"; private static string establishment = "c1"; static void Main() { try { var guiForm = new GuiForm(); // Instantiating the Form-derived class. string deliveriesListResp = getOrders(); Processing... foreach (...) { if ((bool)DBresponse["status"]) {

Copying control components

邮差的信 提交于 2019-12-25 00:46:54
问题 I have a C++/CLI project which has a child form with some control components. I would like to copy all the control components with their codes on a new Tab control on the main form. How can I do that? 回答1: You can select all of the controls in the designer (hold down the Shift key to make multiple selections), and then cut and paste them to their new location: Ctrl + X , Ctrl + V Alternatively, you can open up the *.Designer file that is generated automatically by the Windows Forms designer

Filtering Listboxes in a Windows Forms application

无人久伴 提交于 2019-12-24 20:06:38
问题 Is it possible to filter the contents of a Listbox in a Windows Forms application? The DataSource of my ListBox is a BindingSource containing a bunch of DTOs in an: IList<DisplayDTO> I want to filter on the DTO property that is specified in the ListBox's DisplayMember. The text to be filtered on is provided in a separate Text Box. 回答1: This should work : private void textBox_TextChanged(object sender, EventArgs e) { bindingSource.Filter = string.Format("[{0}] LIKE '%{1}%'", listBox

Abbreviate serialization in .Designer

我们两清 提交于 2019-12-24 17:39:11
问题 I have a custom control with a property of type Foo . I created an UITypeEditor for this class. This works well and results in designer code like: Dim Foo1 As PropertySerialization.Foo = New PropertySerialization.Foo() Me.FooControl1 = New PropertySerialization.FooControl() Me.SuspendLayout() ' 'FooControl1 ' Me.FooControl1.Location = New System.Drawing.Point(35, 56) Me.FooControl1.Name = "FooControl1" Me.FooControl1.Size = New System.Drawing.Size(188, 136) Foo1.A = 3 Foo1.B = "World" Me

Avoid exceptions from PropertyGrid

 ̄綄美尐妖づ 提交于 2019-12-24 12:51:42
问题 In my sample I have used a PropertyGrid control and fetched my all properties and values. When I change one property to an invalid value, like "123456789008765" for an integer field, it throws the following error: I need to avoid this error, and if the given value is invalid I need to assign a default value (in this case 13, 13 ). How can I do this? 回答1: Short Answer The PropertyGrid uses the TypeConverter to convert a string to your property value and convert your property value to a string

Visual Studio Windows Form Preview In Different Resolution?

夙愿已清 提交于 2019-12-24 07:52:27
问题 I enjoy running Visual Studio in 1680 x 1050 resolution. However, our customers typically use 1024 x 768. Is there some way I can keep my editor in the native resolution but display the form designer in a different one? Thanks! Austin 回答1: I suggest you get an additional monitor, configure it as a desktop extension at 1024 x 768, and use it as your UI development and testing screen. 回答2: I use a 2nd monitor at lower resolution when I need something like this. Keep VS in your main window, then

.NET Windows Forms custom designer doesn't refresh the menu

我与影子孤独终老i 提交于 2019-12-24 02:45:10
问题 I have created a custom designer ( PannelloSfondoDesigner ) for my custom control, a background panel ( PannelloSfondo ). <Designer(GetType(PannelloSfondo.PannelloSfondoDesigner))> Public Class PannelloSfondo Inherits UserControl Friend Class PannelloSfondoDesigner Inherits ParentControlDesigner Public Overrides Sub Initialize(ByVal component As IComponent) MyBase.Initialize(component) verbDock = New DesignerVerb("Dock to parent container", New EventHandler(AddressOf Me.OnDock)) verbUndock =