Jump to content
Xtreme .Net Talk

Search the Community

Showing results for tags 'user'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • New Member at Xtreme .Net Talk?
    • Meet and Greet
    • Announcements
  • .NET
    • General
    • Windows Forms
    • ASP.NET
    • Directory / File IO / Registry
    • Database / XML / Reporting
    • Network
    • Graphics and Multimedia
    • Interoperation / Office Integration
    • Deployment
    • Regular Expressions
    • Syntax Specific
  • Knowledge Base
    • Tutors Corner
    • Code Library
    • Quick Tips
  • Xtreme .Net Talk Members Area
    • Water Cooler
    • Suggestions, Bugs, and Comments

Blogs

There are no results to display.

Categories

  • Code Samples
  • Tutorials & Guides
  • Articles
  • Code Downloads

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Location


Occupation


Visual Studio .NET Version


.NET Preferred Language


Skype


Facebook


Twitter ( X )

Found 1 result

  1. Afternoon all, I have a little project that represents a petrol station. I have a user control that represents a petrol-pump. These can be added and removed dependant on how many are required. In my user control I have a combo-box that holds the fuel choices {Diesel, Premium, Unleaded} for example. The problem I have is that when I select a fuel in one instance of a user control, it also changes the selection in all other instances. I thought they would be completely independant of one another? How can I achieve this? I want to have one pump running Diesel, whilst the others can be running Unleaded or Premium. My code is below - I'm currently adding them dynamically with a click, I have however tried adding them prior to runtime in the designer, but I get the same result. private void btnAddPump_Click(object sender, EventArgs e) { //creates a petrolpump control instance and assigns a pump identifier //tlpPumpControlHolder.Controls.Add(new PetrolPump()); PetrolPump pumpInstance = new PetrolPump(_pumpIndex); tlpPumpControlHolder.Controls.Add(pumpInstance); //increment unique identifier _pumpIndex++; //needs calling to update fuel list for new pumps UpdatePumpsWithFuels(); } using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace PumpingStation_RunThrough { public partial class PetrolPump : UserControl { private int pumpIndex; //is this needed? private List<Fuel> _fuelList; private Fuel _selectedFuel; #region Constructors public PetrolPump() { InitializeComponent(); } public PetrolPump(int PumpIndex) { pumpIndex = PumpIndex; if (InvokeRequired) { MethodInvoker theFunction = new MethodInvoker(PetrolPump_ASync); Invoke(theFunction, null); } else { PetrolPump_ASync(); } pumpIndex = PumpIndex; //InitializeComponent(); //ThreadPool.QueueUserWorkItem(new WaitCallback(PetrolPump_ASync)); } private void PetrolPump_ASync() { //pumpIndex = PumpIndex; InitializeComponent(); } #endregion public List<Fuel> FuelList { get { return _fuelList; } set { _fuelList = value; UpdateFuelCombobox(); } //extra stuff to go here. When set is called a method will be required to update the PetrolPumps fuel combobox } private void UpdateFuelCombobox() { //make threadsafe if (InvokeRequired) { MethodInvoker theFunction = new MethodInvoker(UpdateFuelCombobox); } else { this.cmbFuelSelection.DataSource = null; this.cmbFuelSelection.DataSource = _fuelList; } } } } Please bear in mind that I had the same problem prior to attempting to make it asynchronous. Kind regards, Mike.
×
×
  • Create New...