Combobox


Author
Message
Ian Johnston
Ian Johnston
StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)
Group: StrataFrame Users
Posts: 77, Visits: 470
I have a combobox that I wish to populate from a customer file and add the foreign key in another table based on which customer is selected. Do I have to use a businessBindingSource ?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Not sure what you mean by "customer file". Do you mean that the data is in an XML file...a plain text file...?



The SF Combos have some very nice features to fill them with data from a BO (which can be in a database, XML file) or from an enum. If you could provide some more details, myself or someone else will be happy to help.
Ian Johnston
Ian Johnston
StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)StrataFrame User (151 reputation)
Group: StrataFrame Users
Posts: 77, Visits: 470
Sorry, the customers data is from a BO going into another BO. I have set the parent child relationship property in the child BO. Parent primary key is cust_pk, child foreign key is FK_Customer.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
No, you do not need to use the BusinessBindingSOurce. Instead of trying to explain all of the features of a combo box, I will direct you towards some of the samples and give a brief example here. I highly recommend downloading the StrataFlix sample as this is going to be shown a number of times in the maintenance dialogs. Also, there are some additional samples that come with the framework, specifically Multi-Combo Sample (shows how to have multiple columns, but also shows how to use the PopulationDataSourceSettings). This sample will first show you how to use the PopulationDataSourceSettings, not populate from a foreign key, but this is the first step to understanding combo population.



Next, you can create a Fill method on your BO that loads the child records (or you may be able to use the FillByParentPrimaryKey method if this is truly a foreign key and has been setup on your BO). This method will accept a parameter (i.e. the primary key of the parent record). You will then supply this value in the ListPopulating event of the combo box (which is the foreign key) and the combo will populate with the child records.



I know that I have given you a 10000 foot view here. The reason is that there are a lot of samples as well as documentation showing how to do this so I was just trying to give an overview instead of step by step.



I HIGHLY recommend getting the StrataFlix sample running as we will use this as a direct reference through this forum to get you going as there are samples to cover all of these types of things in there giving a more real world example.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This can be easily done with a SF Combo. There are two help topics that explain this in great detail.



Check out the List Population help topic (its under the Application Framework/UI Layer/Controls area). This describes how to load the combo (or listbox or checked listbox), including how to set a value for the combo (which you will bind to), vs. configuring the display text.



Also see the Data Binding topic for information on how to bind the combo to a value in the BO (the FK).



Let us know if you need more help.
Les Pinter
Les Pinter
StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Hi Ian,

    Here's a little sample that uses the result of scrolling the combobox to stick the cust_pk of the selected customer back into the company field of the selected customer record. It's a funny example, but I didn't want to involve two tables, but the logic is the same to stuff the cust_pk into a field in another table. My combobox uses a business object method called FillTop100() to load the first 100 customers. I also have a little label beside my combobox to show that it's working. The PopulationDataSourceSettings dialog hopefully show what's required.

using System;

namespace ViewTest
{
  public partial class Form1 : MicroFour.StrataFrame.UI.Windows.Forms.StandardForm
  {
    public Form1()
    { InitializeComponent();
      customerBO1.FillTop100();
    }

    private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
    {
    if (comboBox1.SelectedValue != null)
      { customerBO1.SeekToPrimaryKey(comboBox1.SelectedValue.ToString());
        customerBO1.cust_Company = comboBox1.SelectedValue.ToString();
        customerBO1.Save();
        label1.Text = customerBO1.cust_Company + " stored in cust_Company";  }
    }
  }
}

Attachments
Snap1.gif (105 views, 17.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search