I don't see the advantage of using the KeyDown event instead of the Leave event. I got to store the value and do everytyhing manually anyway.
Plus neither KeyDOwn nor Leave will catch the cases when the ComboBox is set programmatically.
I guess there is no ComboBox.OnSelectedValueChaged silver bullet.
The TextChanged event fires if your ComboBox.DropDownStyle is set to ComboBoxStyle.DropDown. The unfortunate part is that is fires for every character typed, so you might want to handle the LostFocus event or the Validating event in order to add the new text or to call the function after the text is entered in its entirety.
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:
/// The DbComboBox is dependent on the ServerComboBox and has to display the databases
/// available for the selected server.
class DbComboBox : ComboBox
string m_onEnterServerName = ""; //the name of the server we pulled databases from the last time
/// <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
this.DropDown += new System.EventHandler(ServerChangedEventHandler);
/// Event handler that is called when we suspect that the selection for the server combo box has changed
/// <param name="sender"></param>
/// <param name="e"></param>
private void ServerChangedEventHandler(object sender, System.EventArgs e)
/// Goes to the server, pulls databaselist, populates combobox
public void RefreshVaultDbHistory()
string newServer = m_ServerComboBox.Text;
if ((!newServer.Equals("")) && (!newServer.Equals(m_onEnterServerName)))
I have a software package that gets installed on a local sql server and the customer can run as many clients as they need. What I need to be able to do is license the package by securing the sql server. For each "sub-office" there should be a license. Each sub-office has its own database on the sql server.
I know that this isn't the right forum. I just though maybe I can get a quick answer since this one has a larger audience. If anything I can implement a custom solution not based on the sql server. Suggestions welcomed.
So basically you want to license the database itself? We have a similar setup with our flagship product where a single database manages the accounts that can access each of the company databases (or sub-office database in your case). Similar to you, we allow unlimited user accounts. You could even forego this and just use Windows Authentication using SSPI. The thing that maintains how many people can access each database at a time is a .NET Remoting object that caches the current license count for each company (just in case the Remoting object shuts down or something). It hands out licenses and takes care of decrementing those counts when a client disconnects. The latter part is problematic, however, since if your client application crashes there's not really any good way to decrement the count since the clean-up code didn't run. If you don't have to expose your Remoting object through IIS in order to hang-off port 80, you could always poll clients by implementing your own ILease and returning that in GetLifetimeService.
As far as limiting connections in SQL Server, all you can do is limit licenses for a SQL Server instance, but that's nothing that a DBO couldn't change.
Awesome! That is exactly what I was thinking about doing.
One little question. I have my clients automatically find the sql server (multiple sql servers are possible also, I do searching using SQLDMO.ListAvailableSQLServers). What would be the best way of storing the URI? I was thinking maybe store it on the SQL database and have the client look it up. It URI doesn't work or license check fails then client will shutdown.
You have to split this up into two part. First convert then encode and send to server.
Take a look at this site: http://www.verypdf.com/ and see PDFcamp/PDFwriter - it looks like this is the least expensive way of converting html to pdf. If you are looking for more pro components then around at: www.pdfstore.com (Some of the prices out there are scare if you are a startup and dont have much money.)
To put the pdf in database just read the file in and use Convert.ToBase64String() and send it to the database.
You could also - depending on the RDBMS - store the PDF as a binary stream, which some ADO.NET classes (like those in System.Data.SqlClient) support. IMO, you should store the PDF on the filesystem and either store the path in the DB or use the primary key as part of the filename, which is what we do in our flagship product.
I'm using the ".NET Configuration Tool" to change the properties of the permissions belongin' to various permission sets. This can be done using the "Properties" dialog available for any built-in permission.
Is there any way to provide such a dialog for a custom permission, a CodeAccessPermission-derived class? The default displays a message like "The Custom Permission is unrestricted", or an xml fragment
The mscorcfg.dll assembly for the Microsoft .NET Framework Configuration snap-in is hard-coded to display views and property pages for the built-in permission classes and all the abstract classes are marked private. There is nothing in the .NET base class library for this either, unfortunately. You could take a look at the aforementioned assembly to see if there's any other hooks or interfaces, but it doesn't appear to have any.
If I open a form with a axwebbrowser-control in a mdi-container
and show an excel-sheet in the webcontrol, than close the form
and application, the excel-process leaves alive.
If I close the application without closing the form first
The environment variable has to be a system environment variable, or a user environment variable for the user that the service runs as. Adding environment variables from the command-line are also only valid for that instance of the command line, or any programs started from the command line. To configure persistent, global environment variables, go to the Advanced tab of your System Properties (right-click on My Computer and select Properties) and click the Environment Variables button (or similar). You'll see sections for both user and system environment variables there.
There is preproc conditions supported by the C# compiler, yes, but there is no such definitions provided by the compiler that are documented, so you'll have to pass them yourself using /d:SYMBOL or configuring additional symbols in your VS.NET project (go to project properties, expand Configuration Properties, click on Build, and add symbols to the Conditional Compilation Constants at the top). An example follows: