Click here to Skip to main content
15,889,691 members
Home / Discussions / C#
   

C#

 
GeneralRe: sharing internet offline files Pin
Heath Stewart14-Jan-04 4:02
protectorHeath Stewart14-Jan-04 4:02 
GeneralRe: sharing internet offline files Pin
Mohamad Al Husseiny14-Jan-04 19:20
Mohamad Al Husseiny14-Jan-04 19:20 
GeneralGraph classes for C# Pin
crushinghellhammer13-Jan-04 13:50
crushinghellhammer13-Jan-04 13:50 
GeneralRe: Graph classes for C# Pin
scadaguy14-Jan-04 2:42
scadaguy14-Jan-04 2:42 
GeneralRe: Graph classes for C# Pin
Giles14-Jan-04 11:17
Giles14-Jan-04 11:17 
GeneralMarshalling from C# string directly to an MFC CString Pin
jerrycainjr13-Jan-04 13:14
jerrycainjr13-Jan-04 13:14 
GeneralRe: Marshalling from C# string directly to an MFC CString Pin
Heath Stewart14-Jan-04 3:43
protectorHeath Stewart14-Jan-04 3:43 
GeneralAnimating True Type Fonts Pin
mrhicks13-Jan-04 12:01
mrhicks13-Jan-04 12:01 
GeneralRe: Animating True Type Fonts Pin
Heath Stewart13-Jan-04 13:00
protectorHeath Stewart13-Jan-04 13:00 
GeneralRe: Animating True Type Fonts Pin
leppie13-Jan-04 13:45
leppie13-Jan-04 13:45 
GeneralGDI+ missing functionality in PocketPC Pin
Gizz13-Jan-04 7:52
Gizz13-Jan-04 7:52 
GeneralRe: GDI+ missing functionality in PocketPC Pin
Heath Stewart13-Jan-04 8:21
protectorHeath Stewart13-Jan-04 8:21 
GeneralRe: GDI+ missing functionality in PocketPC Pin
leppie13-Jan-04 13:54
leppie13-Jan-04 13:54 
GeneralUnexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Roman R.13-Jan-04 7:20
Roman R.13-Jan-04 7:20 
GeneralRe: Unexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Heath Stewart13-Jan-04 8:40
protectorHeath Stewart13-Jan-04 8:40 
GeneralComboBox events Pin
elena1234513-Jan-04 6:15
elena1234513-Jan-04 6:15 
GeneralRe: ComboBox events Pin
Nick Parker13-Jan-04 6:50
protectorNick Parker13-Jan-04 6:50 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 8:09
elena1234513-Jan-04 8:09 
GeneralRe: ComboBox events Pin
Heath Stewart13-Jan-04 8:49
protectorHeath Stewart13-Jan-04 8:49 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 10:14
elena1234513-Jan-04 10:14 
For those interested, here is what I ended up doing.
But first a little mode details on my case: it's a login dialog, and whenever the value in ServerComboBox changes I have to go and pull a list of databases off the server and put it into the DBComboBox.

This might look like an overkill with ServerComboBox.Leave, ServerComboBox.SelectedIndexChanged, and DBComboBox.DropDown handlers.
I would skip Leave & SelectedIndexChanged and just do DropDown if I didn't have to make a call to the server. When I do the call the the server on DropDown, the GUI hangs a little, so it's better to do it right when the ServerComboBox is changed.

Why do I have the DropDown handler at all: there is one case when Leave & SelectedIndexChanged don't do it: on startup when there is no history in the registry and we use the hardcoded default value for the ServerComboBox.

I don't know if I am making sence or it's too specific to my problem. Here it is anyway:
Let me know if you see any way to improve the code.

So here it is:


/// <summary>
/// The DbComboBox is dependent on the ServerComboBox and has to display the databases
/// available for the selected server.
/// </summary>
class DbComboBox : ComboBox
{
string m_onEnterServerName = ""; //the name of the server we pulled databases from the last time
ComboBox m_ServerComboBox;

/// <summary>
/// Constructor
/// </summary>
/// <param name="ServerComboBox">server combo box that we need to display Dbs for</param>
public DbComboBox(ComboBox ServerComboBox):base()
{
m_ServerComboBox = ServerComboBox;

//handles user changes but not programatic updates
//programatic updates are handled by SelectedIndexChange and a call to RefreshDbHistory
//from Server property in the SignIn dialog
m_ServerComboBox.Leave += new System.EventHandler(ServerChangedEventHandler);

//handles selection change, but not when the user types in something new
m_ServerComboBox.SelectedIndexChanged += new System.EventHandler(ServerChangedEventHandler);

//in case there is no history and login defaults we need to load DBs for the
//hardcoded default.
this.DropDown += new System.EventHandler(ServerChangedEventHandler);
}

/// <summary>
/// Event handler that is called when we suspect that the selection for the server combo box has changed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ServerChangedEventHandler(object sender, System.EventArgs e)
{
RefreshDbHistory();
}

/// <summary>
/// Goes to the server, pulls databaselist, populates combobox
/// </summary>
public void RefreshVaultDbHistory()
{
string newServer = m_ServerComboBox.Text;
if ((!newServer.Equals("")) && (!newServer.Equals(m_onEnterServerName)))
{
....
}
}
}


Elena
Generalunzip zip file Pin
murali_utr13-Jan-04 6:00
murali_utr13-Jan-04 6:00 
GeneralRe: unzip zip file Pin
Judah Gabriel Himango13-Jan-04 6:14
sponsorJudah Gabriel Himango13-Jan-04 6:14 
GeneralRe: unzip zip file Pin
murali_utr13-Jan-04 9:20
murali_utr13-Jan-04 9:20 
QuestionLicensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 4:56
Alex Korchemniy13-Jan-04 4:56 
AnswerRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 5:39
protectorHeath Stewart13-Jan-04 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.