Search Results

Search found 2806 results on 113 pages for 'winforms'.

Page 4/113 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • IoC/DI in the face of winforms and other generated code

    - by Kaleb Pederson
    When using dependency injection (DI) and inversion of control (IoC) objects will typically have a constructor that accepts the set of dependencies required for the object to function properly. For example, if I have a form that requires a service to populate a combo box you might see something like this: // my files public interface IDataService { IList<MyData> GetData(); } public interface IComboDataService { IList<MyComboData> GetComboData(); } public partial class PopulatedForm : BaseForm { private IDataService service; public PopulatedForm(IDataService service) { //... InitializeComponent(); } } This works fine at the top level, I just use my IoC container to resolve the dependencies: var form = ioc.Resolve<PopulatedForm>(); But in the face of generated code, this gets harder. In winforms a second file composing the rest of the partial class is generated. This file references other components, such as custom controls, and uses no-args constructors to create such controls: // generated file: PopulatedForm.Designer.cs public partial class PopulatedForm { private void InitializeComponent() { this.customComboBox = new UserCreatedComboBox(); // customComboBox has an IComboDataService dependency } } Since this is generated code, I can't pass in the dependencies and there's no easy way to have my IoC container automatically inject all the dependencies. One solution is to pass in the dependencies of each child component to PopulatedForm even though it may not need them directly, such as with the IComboDataService required by the UserCreatedComboBox. I then have the responsibility to make sure that the dependencies are provided through various properties or setter methods. Then, my PopulatedForm constructor might look as follows: public PopulatedForm(IDataService service, IComboDataService comboDataService) { this.service = service; InitializeComponent(); this.customComboBox.ComboDataService = comboDataService; } Another possible solution is to have the no-args constructor to do the necessary resolution: public class UserCreatedComboBox { private IComboDataService comboDataService; public UserCreatedComboBox() { if (!DesignMode && IoC.Instance != null) { comboDataService = Ioc.Instance.Resolve<IComboDataService>(); } } } Neither solution is particularly good. What patterns and alternatives are available to more capably handle dependency-injection in the face of generated code? I'd love to see both general solutions, such as patterns, and ones specific to C#, Winforms, and Autofac.

    Read the article

  • Winforms Checkbox : CheckState property Indeterminate renders differently

    - by joedotnot
    In C# environment, setting a checkbox's CheckState property to Indeterminate displays a "green square" inside the checkbox. In VB environment, this displays as a "grayed out check" (which is less intuitive, even for "dummy" users). How do i make Indeterminate state look like a "green square" in VB.NET ? Btw, i am using VS2008, Winforms 2.0. (Btw2: I tried to create two tags CheckState Indeterminate, which is more appropriate to my question, but disallowed by StackOverflow due to points!)

    Read the article

  • auto update for winforms application

    - by AnonymousCow
    When creating an auto updating feature for a .net winforms application, how does it update the .dll's and not effect the currently running application? Since the application is running during the update process, won't their be a lock on the .dll's (because those .dll's will have to be overwritten during the update.

    Read the article

  • Speeding Up Slow, CPU-Intensive Scrolling in WinForms

    - by S B
    How can I speed up the scrolling of UserControls in a WinForms app.? My main form has trouble scrolling quickly on slow machines--painting for each of the small scroll increments is CPU intensive. My form has roughly fifty UserControls (with multiple fields) positioned one below the other. I’ve tried intercepting OnScroll and UserPaint in order to eliminate some of the unnecessary re-paints for very small scroll events, but the underlying Paint gets called anyway. How can I streamline scrolling on slower machines?

    Read the article

  • Simple question about WinForms and ListView

    - by Alex
    Hello I have a ListView in my WinForms application. ListWiew has 4 columns. So i want to write string in fourth column on every LisViewItem. When i try it. foreach (ListViewItem item in lvData.Items) { item.SubItems[3].Text ="something"; } i get an exception InvalidArgument=Value of '4' is not valid for 'index'. Parameter name: index What's wrong?

    Read the article

  • Using Custom Cursor WinForms

    - by j-t-s
    Is there a way to use a custom cursor in winforms? There seems to be no option. But when I try to manually add a cursor as a resource, then call it from code, it says that it cannot convert from type byte[] to Cursor.

    Read the article

  • Sql Server Select Command and too much data sent to winforms application

    - by ThanosPapathanasiou
    When you have an application and send a select command, the sql server gathers all the data and sends them back to your application and fills your datagrid (for example) If you performed the same select command in sql management studio, immediately as the query starts running and finding data the results panel would start filling with the data found. How can I do that for my winforms application? Is there a technique or a standard method of doing something like this? Links to good examples would be an immense help. thanks

    Read the article

  • Winforms DataBind to Control's Visible Property

    - by B Z
    WinForms, .NetFramework 3.5 Are there any known issues when databinding to a control's visible property? The control is always NOT visible regardless of what my property is. Public ReadOnly Property IsRibbonCategory() As Boolean Get Return True End Get End Property I tried the control's text property and other properties and they seem to work correctly. I am trying to set a Panel's visible property. Using a BindingSource. Thx in advance.

    Read the article

  • WinForms (C#) Databinding Object to Checkbox.Checked Property

    - by Trevor Sullivan
    Hello, I'm writing a WinForms app, and am trying to bind a boolean property on a .NET object to a Checkbox's "checked" property. I am successfully creating the binding, but when I change the source property's value from false to true (I have a button that toggles it), the checkbox's "checked" property does not reflect that change. if (chkPreRun.DataBindings["Checked"] == null) { Debug.WriteLine("Adding chkPreRun databinding"); Binding _binding = chkPreRun.DataBindings.Add("Checked", NwmConfig, "PreRun") // Added this just to ensure that these were being set properly _binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; _binding.ControlUpdateMode = ControlUpdateMode.OnPropertyChanged; } I am able to successfully bind the text property to the value of a TextBox, for example. I'm not sure what I'm missing while binding to the "Checked" property, however. Cheers, Trevor

    Read the article

  • C# Winforms - SQL Server 2005 stored procedure - parameters from TextBox

    - by Geo Ego
    I'm trying to call a parameterized stored procedure from SQL Server 2005 in my C# Winforms app. I add the parameters like so (there are 88 of them): cmd.Parameters.Add("@CustomerName", SqlDbType.VarChar, 100).Value = CustomerName.Text; I get the following exception: "System.InvalidCastException: Failed to convert parameter value from a TextBox to a String. ---> System.InvalidCastException: Object must implement IConvertible." The line throwing the error is when I call the query: cmd.ExecuteNonQuery(); I also tried using the .ToString() method on the TextBoxes, which seemed pointless anyway, and threw the same error. Am I passing the parameters incorrectly? Thanks for the help.

    Read the article

  • Setting winforms ToolStripMenuItem ShortcutKeys to numpad key does not work

    - by Axarydax
    We have the ability to define ShortcutKeys for WinForms application menu items. That way I can tell a menu item File-Save to have a shortcut key Ctrl+S and the menu item's handler is "magically" executed after pressing Ctrl+S. The trouble is with the numeric keypad keys, the ShortcutKey property does not accept them (I don't understand how are they different from the other acceptable keys. MSDN states that the property accepts type System.Windows.Forms.Keys (One of the Keys values. The default is None.); and an InvalidEnumArgumentException would be thrown when the parameter is not one of Keys values. But for example Keys.Divide IS one of Keys values, and yet it can't be used. So how can I set a menu item to have a shortcut for Numpad * or Numpad +? Do I need to handle the key in Form's ProcessCmdKey event? Thanks

    Read the article

  • Selecting an item in a ListView control ( winforms ) while not having the focus

    - by rahulchandran
    I am trying to mimic the functionality of the address book in Outlook So basically a user starts typing in some text in an edit control and a matching ListView Item is selected private void txtSearchText_TextChanged(object sender, EventArgs e) { ListViewItem lvi = this.listViewContacts.FindItemWithText(this.txtSearchText.Text,true, 0); if (lvi != null) { listViewContacts.Items[lvi.Index].Selected = true; listViewContacts.Select(); } } The problem with this is once the listview item gets selected the user cant keep typing into the text Box. Basically I want a way to highlight an item in the listview while still keeping the focus on the edit control This is WINFORMS 2.0

    Read the article

  • Binding to a WPF hosted control's DependencyProperty in WinForms

    - by Reddog
    I have a WinForms app with some elements that are hosted WPF user controls (using ElementHost). I want to be able to bind my WinForm's control property (Button.Enabled) to a custom DependencyProperty of the hosted WPF user control (SearchResults.IsAccountSelected). Is it possible to bind a System.Windows.Forms.Binding to a property managed by a DependencyProperty? Also, since I know the System.Windows.Forms.Binding watches for INotifyPropertyChanged.PropertyChanged events - will a property backed by a DependencyProperty automatically fire these events or will I have to implement and manage the sending of PropertyChanged events manually?

    Read the article

  • Winforms checkbox Databinding problem

    - by Savvas Sopiadis
    Hello everybody! In a winforms application (VB, VS2008 SP1) i bound a checkbox field to a SQL Server 2005 BIT field. The databinding itself seems to work, there is this litte problem: user creates a new record and checks the checkbox, then the user decides to create a new record (without having saved the previous, so there are 2 new records to be submitted) and checks also the second. Now the user decides to save these records: the result is that only the second record keeps the checked value, the first one is unchecked! (i tried the same with 5 records: the result is the same, the first 4 records are unchecked and only the last one keeps the checked state). What do i miss?? Thanks in advance

    Read the article

  • Winforms ComboBox autocomplete search multiple parts of string

    - by studiothat
    Very similar question to this one... http://stackoverflow.com/questions/522521/autocomplete-for-combobox-in-wpf-anywhere-in-text-not-just-beginning but my issue is for windows-forms rather than WPF. I have a winforms databound combox working great with autocomplete list coming from the data items in the combobox. Of course the client wants it to work "better", and that means that they want the autocomplete to work by searching and showing autocomplete options for any matching (contains()) string not just the starting string (startswith()) I know it's probably not just a property that can be set in the combobox, but can anyone point me in the right direction?

    Read the article

  • Fill WinForms DataGridView From Anonymous Linq Query

    - by mdvaldosta
    // From my form BindingSource bs = new BindingSource(); private void fillStudentGrid() { bs.DataSource = Admin.GetStudents(); dgViewStudents.DataSource = bs; } // From the Admin class public static List<Student> GetStudents() { DojoDBDataContext conn = new DojoDBDataContext(); var query = (from s in conn.Students select new Student { ID = s.ID, FirstName = s.FirstName, LastName = s.LastName, Belt = s.Belt }).ToList(); return query; } I'm trying to fill a datagridview control in Winforms, and I only want a few of the values. The code compiles, but throws a runtime error: Explicit construction of entity type 'DojoManagement.Student' in query is not allowed. Is there a way to get it working in this manner?

    Read the article

  • How to represent "options" for my plugin architecture (C# .NET WinForms)

    - by Joshua
    Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These describe the custom "Options" fields on my Plugins, aka: public class MyPlugin : PluginAbstract, IPlugin { [PluginOption("This controls the color of blah blah blah")] [DefaultValue(Color.Red)] public Color TheColor { get; set; } [PluginOption("The number of blah blah blahs")] [DefaultValue(10)] public int BlahBlahBlahs { get; set; } } So I did all the hard parts: I have all the descriptions, default values, names and types of these custom "plugin options". MY QUESTION IS: When a user loads a plugin, how should I represent these options for them to config? On the back end I'll be using XML for the config, so that's not what I'm asking. I'm asking on the front end: What kind of WinForms control should I use to let users configure the options of a plugin, when there will be an unknown amount of options and different types used etc.?

    Read the article

  • Hardware Emulator / Simulator for Winforms .Net Application

    - by Suneet
    I have a WinForms .Net HMI software which talks to hardware over USB. I check for communication with the hardware at Load time and if communication is active then run it (The hardware manufacturer has provided a communication library to talk over USB). I want to build an emulator for cases when communication with hardware is not possible (not connected) and want the software to run in simulated mode by providing dummy values for different states of hardware. Has anyone implemented something similar? Any pointers will be helpful. Are there any design patterns to handle such implementations. TIA

    Read the article

  • Using RichTextBox SelectionTabs property in winforms

    - by Bala R
    In a winforms application, I'm using a RichTextBox and I'm trying to reduce the output from a '\t' to 4 spaces from whatever the default is. I have this in the form's OnLoad _richTextBox.Text = "1\t2\t3\t4\t5"; _richTextBox.SelectAll(); _richTextBox.SelectionTabs = new int[] {100,200,300,400 }; I have a breakpoint before and after this snippet. The SelectionTabs is set to {int[0]} (empty int array) before and after the assignment. Can anyone tell me why my assignment is not going through?

    Read the article

  • Alternative Input Device(Midi) doesn't prevent Screen Saver in Winforms application

    - by DTig
    I have developed a c# winforms application whereby the user is providing input via a midi connected device. The user will go for long periods without using the keyboard or mouse. When I receive a midi message is there anything I can do to "tell" the system that this counts as user activity (ie key press). I don't want the screen saver or time lockouts to occur, if they are actively using the midi device. I think my request is different than other requests I've seen because they want to disable screen savers for the life of their application whereby I just want midi input I receive to count as user interactivity. Is there something I can call when I receive midi input to signify to the system user activity?

    Read the article

  • How to control docking order in C# WinForms

    - by Tommy
    As the title states, I'm looking for a way to control the order in which the items dock to the top of my control. I've played with the windows form designer, and i cant seem to find what the RightClick->Order->SendToFront is doing, because thats exactly what I want to happen. As far as I can get to happen, as I add my contents to my control, the newest contents is always at the top, and I'd like for the Newer contents to be on the bottom, and the oldest contents to be at the top. Summery: Is there an easy way in WinForms (C#), to control the order in which things dock to the sides of controls?

    Read the article

  • How to print css applied background images with the winforms webbrowser control

    - by Geir-Tore Lindsve
    I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts. Is there a way to make the webbrowser print the background of the displayed document too? Edit: Since I wanted to do this programatically, I opted for this solution: using Microsoft.Win32; ... RegistryKey regKey = Registry.CurrentUser .OpenSubKey("Software") .OpenSubKey("Microsoft") .OpenSubKey("Internet Explorer") .OpenSubKey("Main"); //Get the current setting so that we can revert it after printjob var defaultValue = regKey.GetValue("Print_Background"); regKey.SetValue("Print_Background", "yes"); //Do the printing //Revert the registry key to the original value regKey.SetValue("Print_Background", defaultValue); Another way to handle this might be to just read the value, and notify the user to adjust this himself before printing. I have to agree that tweaking with the registry like this is not a good practice, so I am open for any suggestions. Thanks for all your feedback

    Read the article

  • Winforms - a strange problem a with simple binding

    - by Adi Barda
    Hi Guys, It's hard for me to clearly describe my problem but I'll try. I have a UserControl1 which contains UserControl2 which contains several WinForms controls (most of them DevExpress). I do simple binding to these controls to my datatable fields. So far everything works fine. When I move the focus to a record in the table (by navigating in a grid rows for example) the binding works great, the concurrenmcy manager moves the cursor and everything reflects right in the bounded controls. The problem starts when I add new user UserControl3 above UserControl2 and make UserControl2.Visible = false. Now UserControl3 is shown and UserControl2 exists but not shown. Now when I set UserControl2.Visible = true to show it again the simple binding stops working! I navigate in the grid but either the ConcurrencyManager stops working or the simple binding becomes disconnected. My question: Are there any known issues/ best practices with the binding & concurrency manager? Thanks a lot, Adi Barda

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >