Click here to Skip to main content
15,559,429 members
Home / Discussions / C#
   

C#

 
GeneralRe: GDI+ missing functionality in PocketPC Pin
leppie13-Jan-04 14:54
leppie13-Jan-04 14:54 
GeneralUnexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Roman R.13-Jan-04 8:20
Roman R.13-Jan-04 8:20 
GeneralRe: Unexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Heath Stewart13-Jan-04 9:40
protectorHeath Stewart13-Jan-04 9:40 
GeneralComboBox events Pin
elena1234513-Jan-04 7:15
elena1234513-Jan-04 7:15 
GeneralRe: ComboBox events Pin
Nick Parker13-Jan-04 7:50
protectorNick Parker13-Jan-04 7:50 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 9:09
elena1234513-Jan-04 9:09 
GeneralRe: ComboBox events Pin
Heath Stewart13-Jan-04 9:49
protectorHeath Stewart13-Jan-04 9:49 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 11:14
elena1234513-Jan-04 11: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 7:00
murali_utr13-Jan-04 7:00 
GeneralRe: unzip zip file Pin
Judah Gabriel Himango13-Jan-04 7:14
sponsorJudah Gabriel Himango13-Jan-04 7:14 
GeneralRe: unzip zip file Pin
murali_utr13-Jan-04 10:20
murali_utr13-Jan-04 10:20 
QuestionLicensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 5:56
Alex Korchemniy13-Jan-04 5:56 
AnswerRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 6:39
protectorHeath Stewart13-Jan-04 6:39 
GeneralRe: Licensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 6:49
Alex Korchemniy13-Jan-04 6:49 
GeneralRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 6:52
protectorHeath Stewart13-Jan-04 6:52 
GeneralConvert HTML to PDF Stream into DB Pin
Regardt13-Jan-04 3:54
Regardt13-Jan-04 3:54 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Alex Korchemniy13-Jan-04 5:48
Alex Korchemniy13-Jan-04 5:48 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Heath Stewart13-Jan-04 6:32
protectorHeath Stewart13-Jan-04 6:32 
GeneralCustom permissions Pin
Hans Ruck13-Jan-04 2:43
Hans Ruck13-Jan-04 2:43 
GeneralRe: Custom permissions Pin
Heath Stewart13-Jan-04 6:30
protectorHeath Stewart13-Jan-04 6:30 
GeneralRe: Custom permissions Pin
Hans Ruck13-Jan-04 23:21
Hans Ruck13-Jan-04 23:21 
Generalaxwebbrowser excel mdicontainer Pin
mylitziname12-Jan-04 23:28
mylitziname12-Jan-04 23:28 
GeneralRe: axwebbrowser excel mdicontainer Pin
mylitziname13-Jan-04 0:24
mylitziname13-Jan-04 0:24 
GeneralEnvironment variable Pin
cfl12-Jan-04 23:03
cfl12-Jan-04 23:03 
GeneralRe: Environment variable Pin
mylitziname13-Jan-04 0:33
mylitziname13-Jan-04 0:33 

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.