Page 1 of 1

USING A DINAMIC DATASOURCE DEPENDING SELECTEDKEY OF OBJECT LOOKUPBOX

Posted: Mon Apr 16, 2012 11:33 am
by Saus86
Hi

I use in StiForm two LookupBox, in Lookupbox1 i have loaded a DataSourceA and i set from interface in field (DataBindings) in Items a column and in Keys another column of my DataSourceA. This DataSourceA have property Connect on Start=True.



In the LookupBox2 i want load a "dinamic" DataSourceB i.e. its content changes according to the value selected from Lookupbox1 (changing
query of this DataSourceB) Is Possibile??
I have try to set property Item and Keys of Lookupbox2 not from interface but in code writing in event LOadForm...

(AskBOMforItem is LookupBox2 and SelectionsBOMFilter the DataSource)
...
this.AskBOMforItem.ItemsBinding = "SelectionsBOMFilter.Voice";
this.AskBOMforItem.KeysBinding = "SelectionsBOMFilter.IdERP";
...
But this 2 command no function.... (this 2 command function only in section "InitializeComponent")

Then (inside event SelectedIndexChanged of Lookupbox1 ) i want know how modify SqlCommand of DataSourceB and rebinding this contents
in property Item and Keys of Lookupbox2!!!


Thanks :)

USING A DINAMIC DATASOURCE DEPENDING SELECTEDKEY OF OBJECT LOOKUPBOX

Posted: Mon Apr 16, 2012 11:33 am
by Saus86
But this 2 command no function.... please help me
Thanks;)

USING A DINAMIC DATASOURCE DEPENDING SELECTEDKEY OF OBJECT LOOKUPBOX

Posted: Wed Apr 18, 2012 4:59 am
by HighAley
Hello.
Saus86 wrote:I use in StiForm two LookupBox, in Lookupbox1 i have loaded a DataSourceA and i set from interface in field (DataBindings) in Items a column and in Keys another column of my DataSourceA. This DataSourceA have property Connect on Start=True.



In the LookupBox2 i want load a "dinamic" DataSourceB i.e. its content changes according to the value selected from Lookupbox1 (changing
query of this DataSourceB) Is Possibile??
I have try to set property Item and Keys of Lookupbox2 not from interface but in code writing in event LOadForm...

(AskBOMforItem is LookupBox2 and SelectionsBOMFilter the DataSource)
...
this.AskBOMforItem.ItemsBinding = "SelectionsBOMFilter.Voice";
this.AskBOMforItem.KeysBinding = "SelectionsBOMFilter.IdERP";
...
But this 2 command no function.... (this 2 command function only in section "InitializeComponent")

Then (inside event SelectedIndexChanged of Lookupbox1 ) i want know how modify SqlCommand of DataSourceB and rebinding this contents
in property Item and Keys of Lookupbox2!!!
Please, send us your report template with data for analysis.

Thank you.

USING A DINAMIC DATASOURCE DEPENDING SELECTEDKEY OF OBJECT LOOKUPBOX

Posted: Wed Apr 18, 2012 8:52 am
by Saus86
Problem Resolved...thank you anyway!!

i have used a DataSourceA binded in a LookUpBox (AskItem) and i use another DataSourceB (SelectionsBOMFilter) using property: Next() First eof ecc.. for acces datas. Then i use a StiComboboxcontrol (AskBOMItem) for insert inside the items of DataSourceB. All this according to the value of a condition.

Below the example

i insert this code in event Selectindexchanged of Lookupbox "AskItem"

int length=SelectionsBOMFilter.Rows.Count;
this.AskBOMItem.Control.Items.Clear();

int row=0;
bool PresenceBOM=false, FirstElementBOM=true;
SelectionsBOMFilter.First();
//while (!SelectionsBOMFilter.IsEof)
while (row<length)
{
if (this.SelectionsBOMFilter.IdItem==System.Convert.ToInt64(AskItem.SelectedKey))
{
this.AskBOMItem.Control.Items.Add(SelectionsBOMFilter.Voice);
if(FirstElementBOM)
{
//metto nel parametro il codice IdBOM della prima BOM che trovo per quell Item
ParamIdBOM=SelectionsBOMFilter.IdBOM;
FirstElementBOM=false;
this.Parametro.Text=""+ParamIdBOM;
}
PresenceBOM=true;
}
SelectionsBOMFilter.Next();
row++;
}
if(!PresenceBOM)
{
this.AskBOMItem.Control.Items.Add("Nessuna Distinta associata");
ParamIdBOM=-1;
this.Parametro.Text =System.Convert.ToString(ParamIdBOM);
}
this.AskBOMItem.SelectedIndex = 0;

I hope it's useful to someone
Thanks

USING A DINAMIC DATASOURCE DEPENDING SELECTEDKEY OF OBJECT LOOKUPBOX

Posted: Fri Apr 20, 2012 4:12 am
by HighAley
Hello.

Thank you for solution of the problem.