Click here to Skip to main content
15,906,645 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Licensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 5:49
Alex Korchemniy13-Jan-04 5:49 
GeneralRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 5:52
protectorHeath Stewart13-Jan-04 5:52 
GeneralConvert HTML to PDF Stream into DB Pin
Regardt13-Jan-04 2:54
Regardt13-Jan-04 2:54 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Alex Korchemniy13-Jan-04 4:48
Alex Korchemniy13-Jan-04 4:48 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Heath Stewart13-Jan-04 5:32
protectorHeath Stewart13-Jan-04 5:32 
GeneralCustom permissions Pin
Hans Ruck13-Jan-04 1:43
Hans Ruck13-Jan-04 1:43 
GeneralRe: Custom permissions Pin
Heath Stewart13-Jan-04 5:30
protectorHeath Stewart13-Jan-04 5:30 
GeneralRe: Custom permissions Pin
Hans Ruck13-Jan-04 22:21
Hans Ruck13-Jan-04 22:21 
Generalaxwebbrowser excel mdicontainer Pin
mylitziname12-Jan-04 22:28
mylitziname12-Jan-04 22:28 
GeneralRe: axwebbrowser excel mdicontainer Pin
mylitziname12-Jan-04 23:24
mylitziname12-Jan-04 23:24 
GeneralEnvironment variable Pin
cfl12-Jan-04 22:03
cfl12-Jan-04 22:03 
GeneralRe: Environment variable Pin
mylitziname12-Jan-04 23:33
mylitziname12-Jan-04 23: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.