Ok I have a problem, I am working on a C# project that connects to my MySQL Database via odbc and I have it set up so I enter information password and username to connect to the database on the MainForm (the MainForm is set up for parent / MDI) once a connection has been established I will than select the table I want from the populated combobox, for example I would select contacts, once contacts has been selected it will open a new windows form within the parent form (MainForm).
Once that new MDIChild form is open I want to be able to access the open database connection from my main form, so I can enter information and save it to the database. I have pretty much everything done other than that.
sorry it if this does not make much sense i have been up sense 3AM going through MEPS for the Navy.
usually I will use global application class that act as session in my application, the global class contains application global variables stored as list (usually i use sorted list). thus this variable can be accessed by other object in application
sample of global class like this
public static class GlobalApplication
private static SortedList<string,> globalVars = new SortedList<string,>();
public static void AddGlobalVar(string variableName, object variableValue)
public static object GetGlobalVar(string variableName)
by use that class u have to add your database connection or other object to store to global variable and access it within your application. i.e
I have a base class that implements the methods "DoSomething()" and make it virtual
a) Is there anyway I can force the derivated class to override it too
b) I can't make it abstract, because I need something to be done in the base and in the derivated class
c) I also would like to force the programmer to call base.DoSomething() inside it's own method to be sure the base method to be executed too.
If I have a log method, that I'd like to be called from inside every method, is there anyway to get all parameters and values from the function where it's been called without having to specify one by one?
This is what I would try:
create a non-virtual public or protected method "PseudoVirtual()" that calls two other
methods say "fixd()" and "virtuaal()";
stuff whatever needs to be done anyway in private fixd();
and provide a protected virtual "virtuaal()" which, when overriden, effectively provides
overrides for "PseudoVirtual" while enforcing a call to "fixd()".
I don't think that is possible (unless you write some code that modifies your IL code).
If it can be done, I'm interested!
I have to pass pixelformat as a parameter when performing lockbits. But for grayscale images, there is only "Format16bppGrayscale." Does this format work with 8 bit grayscale images? If not, how do i use lockbits with 8bit grayscale images?
I have a form with a listbox controls that has some items in it.
When i double click a item from the listbox it opens a new form that as the title of the item.
(you will see that on some chat applications)
OK, code for the above is fine.
Now, i don´t want to open new forms with the same title, i want to prevent that.
If a form titled "bob" already exists and i double click "bob" item from the listbox, i want the existing form to be focused not open another form with same title!!!
Can anyone help me here?
how can i count forms, get their titles so that a can achive that
i suspect that i have to create some kind of mdiparent/child forms to do that.
you could keep a Dictionary<string,form> that maps titles to Forms, and before opening
a new Form, look for an existing one if any, then act accordingly. You would have to
remove entries when forms get closed then, using the Closed event.
Or use Application.OpenForms and search for a matching title.
I r multithreading! however it's not looking so good... I'm using a beginInvoke to fire off pings at other machines on my network I'm pulling the names from ldap sychronously. Anyways the question i had was "Are async delegates manged by the threadpool"... I thought i read somewhere that they were indeed managed via the threadpool... So next question is how come when i do something like this "ThreadPool.SetMaxThreads(10,10);" The app still fires off the max threads that the threadpool can manage? I.e. 20-25... Hope someone can shed some light on this.. Lemme know if you would like to see some code if that would help define my question/problem! Thanks in advance for any reply's even if it's stfu noobzor and go read a book!
I know the human being and fish can coexist peacefully. -George Dubya Bush