473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Data.OleDb;

using SAS.EG.AddIns;

namespace Sausag

{

/// <summary>

/// Summary description for CharacterizeDataForm.

/// </summary>

public class SausagForm : System.Windows.Forms.Form

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container 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>

/// ISASTaskConsumer, our hook to the host application for services

/// </summary>

public ISASTaskConsumer Consumer

{

set

{

consumer = value;

}

}

private ISASTaskConsumer 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.DataTable dataTable1;

private System.Data.DataColumn dataColumn1;

private System.Data.DataColumn dataColumn2;

private System.Data.DataSet dsVMember;

private System.Windows.Forms.Label lblData;

public SausagForm()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

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 InitializeComponent()

{

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.DataSet();

this.dataTable1 = new System.Data.DataTable();

this.dataColumn1 = new System.Data.DataColumn();

this.dataColumn2 = new System.Data.DataColumn();

((System.ComponentModel.ISupportInitialize)(this.d sVMember)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.d ataTable1)).BeginInit();

this.SuspendLayout();

//

// lblLib

//

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

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

this.lblLib.Name = "lblLib";

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

this.lblLib.TabIndex = 2;

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

//

// btnOK

//

this.btnOK.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Right)));

this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;

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

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

this.btnOK.Name = "btnOK";

this.btnOK.TabIndex = 11;

this.btnOK.Text = "OK";

//

// btnCancel

//

this.btnCancel.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Right)));

this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.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.Location = new System.Drawing.Point(5, 12);

this.label1.Name = "label1";

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

this.label1.TabIndex = 0;

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

//

// cmbServers

//

this.cmbServers.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Wind ows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.cmbServers.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

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.SelectedIndexChanged += new
System.EventHandler(this.cmbServers_SelectedIndexC hanged);

//

// cmbLibs

//

this.cmbLibs.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Wind ows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.cmbLibs.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

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

this.cmbLibs.Name = "cmbLibs";

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

this.cmbLibs.TabIndex = 2;

this.cmbLibs.SelectedIndexChanged += new
System.EventHandler(this.cmbLibs_SelectedIndexChan ged);

//

// lblData

//

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

this.lblData.Name = "lblData";

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

this.lblData.TabIndex = 5;

this.lblData.Text = "Selected data:";

//

// label3

//

this.label3.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));

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

this.label3.Name = "label3";

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

this.label3.TabIndex = 9;

this.label3.Text = "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.EventHandler(this.txtCatobs_TextChanged);

//

// cmbMembers

//

this.cmbMembers.DataSource = this.dsVMember;

this.cmbMembers.DisplayMember = "vmember.memname";

this.cmbMembers.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

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.SelectedIndexChanged += new
System.EventHandler(this.cmbMembers_SelectedIndexC hanged);

//

// dsVMember

//

this.dsVMember.DataSetName = "data";

this.dsVMember.Locale = new System.Globalization.CultureInfo("en-AU");

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

this.dataTable1});

//

// dataTable1

//

this.dataTable1.Columns.AddRange(new System.Data.DataColumn[] {

this.dataColumn1,

this.dataColumn2});

this.dataTable1.TableName = "vmember";

//

// dataColumn1

//

this.dataColumn1.ColumnName = "memname";

//

// dataColumn2

//

this.dataColumn2.ColumnName = "memtype";

//

// SausagForm

//

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

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

this.Controls.Add(this.cmbMembers);

this.Controls.Add(this.txtCatobs);

this.Controls.Add(this.label3);

this.Controls.Add(this.lblData);

this.Controls.Add(this.cmbLibs);

this.Controls.Add(this.cmbServers);

this.Controls.Add(this.label1);

this.Controls.Add(this.btnCancel);

this.Controls.Add(this.btnOK);

this.Controls.Add(this.lblLib);

this.MaximizeBox = false;

this.MinimizeBox = false;

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

this.Name = "SausagForm";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParen t;

this.Text = "Characterize Data";

this.Load += new System.EventHandler(this.CharacterizeDataForm_Load );

((System.ComponentModel.ISupportInitialize)(this.d sVMember)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.d ataTable1)).EndInit();

this.ResumeLayout(false);

}

#endregion

private void CharacterizeDataForm_Load(object sender, System.EventArgs e)

{

if (consumer == null)

throw new System.Exception("Must set ISASTaskConsumer as Consumer
property!");

// get the list of available servers from the application

string[] servers;

consumer.Servers(out servers);

if (servers.Length == 0)

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

// populate the servers combobox

cmbServers.Items.AddRange(servers);

if (consumer.AssignedServer.Length>0)

cmbServers.SelectedItem = consumer.AssignedServer;

currServer = cmbServers.SelectedItem.ToString();

PopulateLibraryList();
txtCatobs.Text = catobs;
// UpdateControls();

}

private void PopulateLibraryList()

{

Cursor c = Cursor.Current;

Cursor.Current = Cursors.WaitCursor;

cmbLibs.Items.Clear();

string[] libs;

consumer.Libraries(cmbServers.SelectedItem.ToStrin g(), out libs);

if (libs.Length == 0)

{

Cursor.Current = c;

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

}

cmbLibs.Items.AddRange(libs);

if (cmbLibs.Items.Contains(library))

cmbLibs.SelectedItem = library;

else

cmbLibs.SelectedIndex = 0;

Cursor.Current = c;

}

// uses the Workspace property of the ISASTaskConsumer

// and the SAS IOM OLEDB Provider to connect to

// the SAS session and query for additional information

// about the SAS data

private void PopulateDatasetList(string libname)

{
string server = "";

SAS.Workspace ws = null;

try

{

server = consumer.AssignedServer;

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

}

catch (Exception ex)

{

throw new System.Exception("ISASTaskConsumer.Workspace is not usable!",ex);

}

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

{

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

ADODB.Connection adoconnect = new ADODB.ConnectionClass();

try

{

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

ws.UniqueIdentifier, "", "", 0);

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

adorecordset.Open( selectclause, adoconnect,

ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly,
(int) ADODB.CommandTypeEnum.adCmdText);

OleDbDataAdapter da = new OleDbDataAdapter();

da.Fill(dsVMember, adorecordset, "vmember");

}

catch

{

}

finally

{

adoconnect.Close();

}

}

}

private void cmbServers_SelectedIndexChanged(object sender,

System.EventArgs e)

{

try

{

PopulateLibraryList();

currServer = cmbServers.SelectedItem.ToString();

}

catch

{

MessageBox.Show(string.Format("There was an error trying to connect to
\"{0}\".", cmbServers.SelectedItem),"Connection error");

cmbServers.SelectedItem = currServer;

}

}

private void cmbLibs_SelectedIndexChanged(object sender, System.EventArgs e)

{

try

{

library = cmbLibs.SelectedItem.ToString();

PopulateDatasetList(library);

}

catch

{

MessageBox.Show(string.Format("There was an error trying to access\"{0}\".",
cmbLibs.SelectedItem),"Connection error");

cmbLibs.SelectedItem = library;

}

}
private void OnCurrentDataCellChanged(object sender, System.EventArgs e)

{

try

{

DataSet ds = cmbMembers.DataSource as DataSet;

members = cmbServers.SelectedIndex.ToString();

}

catch

{

}

}

private void txtCatobs_TextChanged(object sender, System.EventArgs e)

{

try

{

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

catobs = Convert.ToString(txtCatobs.Text);

}

catch

{

}

}

private void cmbMembers_SelectedIndexChanged(object sender,

System.EventArgs e)

{

members=((DataRowView)cmbMembers.SelectedItem).Row .ItemArray[0].ToString();

}

}

}

//
Nov 17 '05 #1
0 2016

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

Similar topics

2
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...
2
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...
5
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...
1
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. ...
3
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...
5
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...
1
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...
2
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....
4
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.