473,591 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unresolved combobox refresh - (repost)

This is a repost of an item that I still cannot resolve.

I have 3 combo boxes. The first leads to the second to the third.

When I have selected a value in the second box, the third box shows the
available information based on the second combo box selection. But if I
change my mind and select a different item in the second box, after the
third box has been populated, the third box still retains the information
that was previously selected.

I need to make the third box capable of being refreshed based on a change of
mind from the second. I was told by a previous response that there is
probably an unreported exception, but I am unable to find this - and i a
realy struggling here.

Any assistance kindly appreciated.

//Code//
using System;

using System.Drawing;

using System.Collecti ons;

using System.Componen tModel;

using System.Windows. Forms;

using System.Data;

using System.Data.Ole Db;

using SAS.EG.AddIns;

namespace Sausag

{

/// <summary>

/// Summary description for CharacterizeDat aForm.

/// </summary>

public class SausagForm : System.Windows. Forms.Form

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.Componen tModel.Containe r components = null;

private System.Windows. Forms.Label lblLib;

private System.Windows. Forms.Button btnOK;

private System.Windows. Forms.Button btnCancel;

private System.Windows. Forms.Label label1;

private System.Windows. Forms.ComboBox cmbServers;

private System.Windows. Forms.ComboBox cmbLibs;

#region Properties for this add-in task

/// <summary>

/// ISASTaskConsume r, our hook to the host application for services

/// </summary>

public ISASTaskConsume r Consumer

{

set

{

consumer = value;

}

}

private ISASTaskConsume r consumer = null;

public string Library

{

set

{

library = value;

}

get

{

return library;

}

}

private string library;

public bool IncludeCharts

{

set

{

bCharts = value;

}

get

{

return bCharts;

}

}

private bool bCharts = false;

public bool AllMembers

{

set

{

bAllData = value;

}

get

{

return bAllData;

}

}

private bool bAllData = false;

public string Members

{

set

{

members = value;

}

get

{

return members;

}

}

private string members;

public string Catobs

{

set

{

catobs = value;

}

get

{

return catobs;

}

}

private string catobs = "10";

#endregion

private string currServer = "";

private System.Windows. Forms.Label label3;

private System.Windows. Forms.TextBox txtCatobs;

private System.Windows. Forms.ComboBox cmbMembers;

private System.Data.Dat aTable dataTable1;

private System.Data.Dat aColumn dataColumn1;

private System.Data.Dat aColumn dataColumn2;

private System.Data.Dat aSet dsVMember;

private System.Windows. Forms.Label lblData;

public SausagForm()

{

//

// Required for Windows Form Designer support

//

InitializeCompo nent();

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Disp ose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeCompo nent()

{

this.lblLib = new System.Windows. Forms.Label();

this.btnOK = new System.Windows. Forms.Button();

this.btnCancel = new System.Windows. Forms.Button();

this.label1 = new System.Windows. Forms.Label();

this.cmbServers = new System.Windows. Forms.ComboBox( );

this.cmbLibs = new System.Windows. Forms.ComboBox( );

this.lblData = new System.Windows. Forms.Label();

this.label3 = new System.Windows. Forms.Label();

this.txtCatobs = new System.Windows. Forms.TextBox() ;

this.cmbMembers = new System.Windows. Forms.ComboBox( );

this.dsVMember = new System.Data.Dat aSet();

this.dataTable1 = new System.Data.Dat aTable();

this.dataColumn 1 = new System.Data.Dat aColumn();

this.dataColumn 2 = new System.Data.Dat aColumn();

((System.Compon entModel.ISuppo rtInitialize)(t his.dsVMember)) .BeginInit();

((System.Compon entModel.ISuppo rtInitialize)(t his.dataTable1) ).BeginInit();

this.SuspendLay out();

//

// lblLib

//

this.lblLib.Fla tStyle = System.Windows. Forms.FlatStyle .System;

this.lblLib.Loc ation = new System.Drawing. Point(5, 44);

this.lblLib.Nam e = "lblLib";

this.lblLib.Siz e = new System.Drawing. Size(166, 23);

this.lblLib.Tab Index = 2;

this.lblLib.Tex t = "Select a library to analyze:";

//

// btnOK

//

this.btnOK.Anch or =
((System.Window s.Forms.AnchorS tyles)((System. Windows.Forms.A nchorStyles.Bot tom
| System.Windows. Forms.AnchorSty les.Right)));

this.btnOK.Dial ogResult = System.Windows. Forms.DialogRes ult.OK;

this.btnOK.Flat Style = System.Windows. Forms.FlatStyle .System;

this.btnOK.Loca tion = new System.Drawing. Point(225, 311);

this.btnOK.Name = "btnOK";

this.btnOK.TabI ndex = 11;

this.btnOK.Text = "OK";

//

// btnCancel

//

this.btnCancel. Anchor =
((System.Window s.Forms.AnchorS tyles)((System. Windows.Forms.A nchorStyles.Bot tom
| System.Windows. Forms.AnchorSty les.Right)));

this.btnCancel. DialogResult = System.Windows. Forms.DialogRes ult.Cancel;

this.btnCancel. FlatStyle = System.Windows. Forms.FlatStyle .System;

this.btnCancel. Location = new System.Drawing. Point(310, 311);

this.btnCancel. Name = "btnCancel" ;

this.btnCancel. TabIndex = 12;

this.btnCancel. Text = "Cancel";

//

// label1

//

this.label1.Loc ation = new System.Drawing. Point(5, 12);

this.label1.Nam e = "label1";

this.label1.Siz e = new System.Drawing. Size(167, 23);

this.label1.Tab Index = 0;

this.label1.Tex t = "Select a SAS server to use:";

//

// cmbServers

//

this.cmbServers .Anchor =
((System.Window s.Forms.AnchorS tyles)(((System .Windows.Forms. AnchorStyles.To p
| System.Windows. Forms.AnchorSty les.Left)

| System.Windows. Forms.AnchorSty les.Right)));

this.cmbServers .DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;

this.cmbServers .Location = new System.Drawing. Point(179, 11);

this.cmbServers .Name = "cmbServers ";

this.cmbServers .Size = new System.Drawing. Size(201, 21);

this.cmbServers .TabIndex = 1;

this.cmbServers .SelectedIndexC hanged += new
System.EventHan dler(this.cmbSe rvers_SelectedI ndexChanged);

//

// cmbLibs

//

this.cmbLibs.An chor =
((System.Window s.Forms.AnchorS tyles)(((System .Windows.Forms. AnchorStyles.To p
| System.Windows. Forms.AnchorSty les.Left)

| System.Windows. Forms.AnchorSty les.Right)));

this.cmbLibs.Dr opDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;

this.cmbLibs.Lo cation = new System.Drawing. Point(177, 42);

this.cmbLibs.Na me = "cmbLibs";

this.cmbLibs.Si ze = new System.Drawing. Size(201, 21);

this.cmbLibs.Ta bIndex = 2;

this.cmbLibs.Se lectedIndexChan ged += new
System.EventHan dler(this.cmbLi bs_SelectedInde xChanged);

//

// lblData

//

this.lblData.Lo cation = new System.Drawing. Point(5, 82);

this.lblData.Na me = "lblData";

this.lblData.Si ze = new System.Drawing. Size(172, 16);

this.lblData.Ta bIndex = 5;

this.lblData.Te xt = "Selected data:";

//

// label3

//

this.label3.Anc hor =
((System.Window s.Forms.AnchorS tyles)((System. Windows.Forms.A nchorStyles.Bot tom
| System.Windows. Forms.AnchorSty les.Left)));

this.label3.Loc ation = new System.Drawing. Point(5, 213);

this.label3.Nam e = "label3";

this.label3.Siz e = new System.Drawing. Size(221, 16);

this.label3.Tab Index = 9;

this.label3.Tex t = "Max records to print in each data set:";

//

// txtCatobs

//

this.txtCatobs. Location = new System.Drawing. Point(292, 211);

this.txtCatobs. Name = "txtCatobs" ;

this.txtCatobs. Size = new System.Drawing. Size(70, 20);

this.txtCatobs. TabIndex = 4;

this.txtCatobs. Text = "10";

this.txtCatobs. TextChanged += new
System.EventHan dler(this.txtCa tobs_TextChange d);

//

// cmbMembers

//

this.cmbMembers .DataSource = this.dsVMember;

this.cmbMembers .DisplayMember = "vmember.memnam e";

this.cmbMembers .DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;

this.cmbMembers .Location = new System.Drawing. Point(178, 79);

this.cmbMembers .Name = "cmbMembers ";

this.cmbMembers .Size = new System.Drawing. Size(201, 21);

this.cmbMembers .TabIndex = 3;

this.cmbMembers .SelectedIndexC hanged += new
System.EventHan dler(this.cmbMe mbers_SelectedI ndexChanged);

//

// dsVMember

//

this.dsVMember. DataSetName = "data";

this.dsVMember. Locale = new System.Globaliz ation.CultureIn fo("en-AU");

this.dsVMember. Tables.AddRange (new System.Data.Dat aTable[] {

this.dataTable1 });

//

// dataTable1

//

this.dataTable1 .Columns.AddRan ge(new System.Data.Dat aColumn[] {

this.dataColumn 1,

this.dataColumn 2});

this.dataTable1 .TableName = "vmember";

//

// dataColumn1

//

this.dataColumn 1.ColumnName = "memname";

//

// dataColumn2

//

this.dataColumn 2.ColumnName = "memtype";

//

// SausagForm

//

this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);

this.ClientSize = new System.Drawing. Size(395, 341);

this.Controls.A dd(this.cmbMemb ers);

this.Controls.A dd(this.txtCato bs);

this.Controls.A dd(this.label3) ;

this.Controls.A dd(this.lblData );

this.Controls.A dd(this.cmbLibs );

this.Controls.A dd(this.cmbServ ers);

this.Controls.A dd(this.label1) ;

this.Controls.A dd(this.btnCanc el);

this.Controls.A dd(this.btnOK);

this.Controls.A dd(this.lblLib) ;

this.MaximizeBo x = false;

this.MinimizeBo x = false;

this.MinimumSiz e = new System.Drawing. Size(403, 368);

this.Name = "SausagForm ";

this.StartPosit ion = System.Windows. Forms.FormStart Position.Center Parent;

this.Text = "Characteri ze Data";

this.Load += new System.EventHan dler(this.Chara cterizeDataForm _Load);

((System.Compon entModel.ISuppo rtInitialize)(t his.dsVMember)) .EndInit();

((System.Compon entModel.ISuppo rtInitialize)(t his.dataTable1) ).EndInit();

this.ResumeLayo ut(false);

}

#endregion

private void CharacterizeDat aForm_Load(obje ct sender, System.EventArg s e)

{

if (consumer == null)

throw new System.Exceptio n("Must set ISASTaskConsume r as Consumer
property!");

// get the list of available servers from the application

string[] servers;

consumer.Server s(out servers);

if (servers.Length == 0)

throw new System.Exceptio n("No servers are available!");

// populate the servers combobox

cmbServers.Item s.AddRange(serv ers);

if (consumer.Assig nedServer.Lengt h>0)

cmbServers.Sele ctedItem = consumer.Assign edServer;

currServer = cmbServers.Sele ctedItem.ToStri ng();

PopulateLibrary List();
txtCatobs.Text = catobs;
// UpdateControls( );

}

private void PopulateLibrary List()

{

Cursor c = Cursor.Current;

Cursor.Current = Cursors.WaitCur sor;

cmbLibs.Items.C lear();

string[] libs;

consumer.Librar ies(cmbServers. SelectedItem.To String(), out libs);

if (libs.Length == 0)

{

Cursor.Current = c;

throw new System.Exceptio n("No libraries are available!");

}

cmbLibs.Items.A ddRange(libs);

if (cmbLibs.Items. Contains(librar y))

cmbLibs.Selecte dItem = library;

else

cmbLibs.Selecte dIndex = 0;

Cursor.Current = c;

}

// uses the Workspace property of the ISASTaskConsume r

// and the SAS IOM OLEDB Provider to connect to

// the SAS session and query for additional information

// about the SAS data

private void PopulateDataset List(string libname)

{
string server = "";

SAS.Workspace ws = null;

try

{

server = consumer.Assign edServer;

ws = consumer.Worksp ace(server) as SAS.Workspace;

}

catch (Exception ex)

{

throw new System.Exceptio n("ISASTaskCons umer.Workspace is not usable!",ex);

}

if (server.Length> 0 && ws!=null)

{

ADODB.Recordset adorecordset = new ADODB.Recordset Class();

ADODB.Connectio n adoconnect = new ADODB.Connectio nClass();

try

{

adoconnect.Open ("Provider=sas. iomprovider.1; SAS Workspace ID=" +

ws.UniqueIdenti fier, "", "", 0);

string selectclause = "select memname, memtype from sashelp.vmember where
libname='" + libname + " ' and memtype = 'DATA'";

adorecordset.Op en( selectclause, adoconnect,

ADODB.CursorTyp eEnum.adOpenFor wardOnly, ADODB.LockTypeE num.adLockReadO nly,
(int) ADODB.CommandTy peEnum.adCmdTex t);

OleDbDataAdapte r da = new OleDbDataAdapte r();

da.Fill(dsVMemb er, adorecordset, "vmember");

}

catch

{

}

finally

{

adoconnect.Clos e();

}

}

}

private void cmbServers_Sele ctedIndexChange d(object sender,

System.EventArg s e)

{

try

{

PopulateLibrary List();

currServer = cmbServers.Sele ctedItem.ToStri ng();

}

catch

{

MessageBox.Show (string.Format( "There was an error trying to connect to
\"{0}\".", cmbServers.Sele ctedItem),"Conn ection error");

cmbServers.Sele ctedItem = currServer;

}

}

private void cmbLibs_Selecte dIndexChanged(o bject sender, System.EventArg s e)

{

try

{

library = cmbLibs.Selecte dItem.ToString( );

PopulateDataset List(library);

}

catch

{

MessageBox.Show (string.Format( "There was an error trying to access\"{0}\"." ,
cmbLibs.Selecte dItem),"Connect ion error");

cmbLibs.Selecte dItem = library;

}

}
private void OnCurrentDataCe llChanged(objec t sender, System.EventArg s e)

{

try

{

DataSet ds = cmbMembers.Data Source as DataSet;

members = cmbServers.Sele ctedIndex.ToStr ing();

}

catch

{

}

}

private void txtCatobs_TextC hanged(object sender, System.EventArg s e)

{

try

{

// catobs = Convert.ToInt32 (txtCatobs.Text );

catobs = Convert.ToStrin g(txtCatobs.Tex t);

}

catch

{

}

}

private void cmbMembers_Sele ctedIndexChange d(object sender,

System.EventArg s e)

{

members=((DataR owView)cmbMembe rs.SelectedItem ).Row.ItemArray[0].ToString();

}

}

}

//
Nov 17 '05 #1
0 2038

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1804
by: Susan Bricker | last post by:
I went back to read my post and found an error in my description ... here is the post, again, corrected: The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the desired key value, and then make the entry with the desired join key in the 'many-only' table."
2
12874
by: John Tyce | last post by:
When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items.Add(string) or ComboBox.Items.Insert(0,string); Either way, the new string does not show up in the ComboBox. I get no errors or problems, it just will not work. At load time I am retrieving dates from an Oracle database and adding them to the ComboBox with out any problems. However, once the application is up and running I cannot add to the...
5
10280
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am trying to do is make an autoscroll combobox. like you have on html textbox's, but this time you hit enter for a change to be made. i do this because i dont want to requery every time a single letter is inputed. it would be too slow. so i make them hit...
1
18089
by: MrNobody | last post by:
I have a ComboBox on my form, and I set it's DataSource to an ArrayList of custom objects. Everything loads fine, all the entries I initially loaded into the ArrayList appear in my ComboBox. However, while my program is running and I add a new object to that ArrayList - this ComboBox is not updating to reflect the change. I have gone so far as to try: clientList.Invalidate();
3
4268
by: ApexData | last post by:
COMBOBOX REFRESH DILEMMA ' I have been working for hours trying to figure out how to requery a combobox in a subform, from a Popup form ' that this subform had launched. Basically, I designed a form that pops up when the user dbl-clicks a combobox. ' This popup form displays the table that the combobox uses. The user can change the content, and the combobox ' rowsource in-turn will change. This all works great in my mainform, but...
5
1495
by: active | last post by:
I tried to use a datasource with a combobox and it didn't work completely so I build a small test that was much more straight forward then the app. The test was to see if the combobox dropdown list displayed the correct data. However, although the designer shows the combobox the combobox does not show at runtime. If you would be so kind as to cut the code below and paste it into a form
1
2132
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add and ComboBox.Items.Insert will behave thusly: -- If the item is not present, add it. -- If the item is present, set the selected index to the item (without adding a duplicate). I know the basics of inheriting from user controls, so if this was merely overriding a method of ComboBox I could do it. I also know how to do this with a couple lines of code in my main...
2
3156
by: billa856 | last post by:
Hi, My project is in MS Access. In that I have one Form in which I have some Comboboxes. 1st one is Independent, 2nd one is dependent on first one, 3rd one is dependent on 1st and 2nd both. After I load the form when I select an item from 1st one it will generate list for 2nd one, then I select an item from 2nd one it will generate list for 3nd one. Uptil this, all r done well. But after these selection if I change the selection of 1st...
4
2458
by: EManning | last post by:
Using A2003 w/ tables linked to SQL Server. All users have their own copy of the mdb. I have a combobox whose rowsource is a query. This query is based on a table and has a field in it that indicates if the record has been selected. When user1 selects the record from the combobox, the field is updated that the record has been selected. If user2 tries to select that same record, they get a warning that user1 has selected it and...
0
7870
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8362
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8225
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6639
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3850
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.