|
Hi all,
I want to show a form in another form not using MdiParent property or in another control and get events(i.e activated, enter).
I can add a form in another form or control setting TopLevel property to false but sub form's events (activated, enter) never works.
A sample for this situation is Microsoft Access. As you know that access is a MDI application. In Access in query design MDI child window the query tables shown as a form. (i.e MDIParent Form --> Query Design MDIChild Form --> query table form(s) ).
I want to develop similar design and I never get sub form's events
Any suggestion?
Thanks in advance...
|
|
|
|
|
Couldn't you define your own events in subform to which mainform subscribes too? Then call them from the subforms eventhandlers for instance?
-Larantz-
|
|
|
|
|
Hi Larantz,
I have two sub forms that in MDIChild form and i want to listen the selected change (or activate) of sub forms.
|
|
|
|
|
Maybe you could do something along the lines of this:
public class ParentForm : Form
{
private SubForm sub1;
private SubForm sub2;
public ParentForm()
{
InitializeSubForms();
}
private void InitializeSubForms()
{
sub1 = new SubForm();
sub1.OnSelectionChanged += new SubForm.SelectionChanged(sub1_OnSelectionChanged);
sub2 = new SubForm();
sub2.OnSelectionChanged += new SubForm.SelectionChanged(sub2_OnSelectionChanged);
}
void sub1_OnSelectionChanged(object sender, EventArgs e)
{
}
void sub2_OnSelectionChanged(object sender, EventArgs e)
{
}
}
public class SubForm : Form
{
private DataGridView dgv;
public delegate void SelectionChanged(object sender, EventArgs e);
public event SelectionChanged OnSelectionChanged;
public SubForm()
{
dgv = new DataGridView();
dgv.SelectionChanged += new EventHandler(dgv_SelectionChanged);
}
void dgv_SelectionChanged(object sender, EventArgs e)
{
if (OnSelectionChanged != null)
OnSelectionChanged(sender, e);
}
}
Best regards!
-Larantz-
|
|
|
|
|
hi friends
are there anybody knows how can i connect a server with username and password with c#? i want to make response with my functions which i take from that server's whdl...
|
|
|
|
|
Hello Experts...
I want to detect the Machine shutdown event...
HOW CAN I DO THAT?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Have a look at the SystemEvents.SessionEnding event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks....
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
private void AddEventHandler()<br />
{<br />
Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(PowerModeChangedSub);<br />
}<br />
<br />
private void PowerModeChangedSub(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)<br />
{<br />
switch (e.Mode)<br />
{<br />
case Microsoft.Win32.PowerModes.Resume:<br />
break;<br />
case Microsoft.Win32.PowerModes.StatusChange:<br />
break;<br />
case Microsoft.Win32.PowerModes.Suspend:<br />
break;<br />
default:<br />
break;<br />
}<br />
}
.:: Something is Wrong ::.
|
|
|
|
|
how can we restrict the value entered in the flexgrid,(ketpress event is not working).They provided one keypressedit event,but its also not working.
My small attempt...
|
|
|
|
|
I've been looking around for a while, and i've found the Marshal.Copy() function, but that's not really what i'm looking for.
Is there any way to actualy copy a managed object in memory, as opposed to instantiating a new one? I don't really want to enter the realms of unmanaged copying, unless i can drop the unmanaged reference at the end of the copy function.
Any thoughts?
cheers
Tris
|
|
|
|
|
Why not serialize your object into a memorystream?
Standards are great! Everybody should have one!
|
|
|
|
|
I looked at it, but its too expensive. I just want to copy the memory footprint wherever the object is and get a pointer / reference to that object.
Serialization is a pretty expensive procedure and i'm really looking at this for creating objects faster than using a constructor.
Might look at copying byte arrays tho.
Cheers
Tris
|
|
|
|
|
I think you'll have to go for unmanaged code if you want it to perform. But I'm no expert. I found this piece of code to clone objects once, but I don't think it performs very well either.
static class Cloner
{
public delegate object CloneDelegate(object o);
private static CloneDelegate cloner;
public static T Clone<T>(T o)
{
if (cloner == null)
{
MethodInfo info = typeof(object).GetMethod("MemberwiseClone",
BindingFlags.Instance | BindingFlags.NonPublic);
cloner = (CloneDelegate)
Delegate.CreateDelegate(typeof(CloneDelegate), null, info);
Debug.Assert(cloner != null);
}
return (T)cloner(o);
}
}
Standards are great! Everybody should have one!
|
|
|
|
|
Can anyone point me in the right direction for declaring a RichTextBox column within a DataGridView...
I know there are a few examples revolving around the Calander control... but... these examples all revolve around editable controls... the displayed control remains a TextBox until it is clicked... which is no good for me... as I want to display each cell as a RichTextBox.
I assume my only option is to derive from DataGridViewCell and override Paint... but my c# is little weak and I'm struggling.
In addition, I may be using a hammer to crack a nut... as all I want to do is to display text in a column which may have some words underlined... from my limited understanding of .net controls... I can only do partial underline with a RichTextBox... thus the need to create a RichTextBox column.
Thanks for anyone who actually reads this... and a double thanks for anyone who replies.
|
|
|
|
|
|
Okay, I have this function that I want to run, it's pretty simple, but for the life of me, It's not working, can someone take a look at it and let me know what you think? It's like connectionStr never gets set, yet the way I call it is MysqlNonQuery("SELECT * FROM account", 1);
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using MySql.Data.MySqlClient;<br />
<br />
namespace mangosAdmin<br />
{<br />
class functions<br />
{<br />
public static string MysqlNonQuery(string sql, int db)<br />
{<br />
string connectionStr;<br />
<br />
if (db == 1)
{<br />
connectionStr = "Database:" + Properties.Settings.Default.mangosDB + ";Source=" + Properties.Settings.Default.mangosHost + ";User Id=" + Properties.Settings.Default.mangosUser + ";Password=" + Properties.Settings.Default.mangosPass;<br />
}<br />
else if (db == 2)
{<br />
connectionStr = "Database:" + Properties.Settings.Default.realmDB + ";Source=" + Properties.Settings.Default.realmHost + ";User Id=" + Properties.Settings.Default.realmUser + ";Password=" + Properties.Settings.Default.realmPass;<br />
}<br />
else<br />
{<br />
connectionStr = "Database:" + Properties.Settings.Default.mangosDB + ";Source=" + Properties.Settings.Default.mangosHost + ";User Id=" + Properties.Settings.Default.mangosUser + ";Password=" + Properties.Settings.Default.mangosPass;<br />
}<br />
try<br />
{<br />
MySqlConnection myConnection = new MySqlConnection(connectionStr);<br />
MySqlCommand myCommand = new MySqlCommand(sql);<br />
myCommand.Connection = myConnection;<br />
myConnection.Open();<br />
myCommand.ExecuteNonQuery();<br />
myCommand.Connection.Close();<br />
}<br />
catch (MySqlException ex)<br />
{<br />
return(ex.Number+ex.Message);<br />
}<br />
<br />
return ("0");<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
|
|
|
|
|
What's the actual error that you're getting from your code?
|
|
|
|
|
i encrypt my database(access) and when my project is running , the database is decrypt and copy on system32 , and after that when the project is closing i delete the database on system32 folder .
it is ok on my computer , but when i run it on another computer , the db decrypt successfully , but in one of my function which i use connection.open , show following error :
could not use ;file already in use
how could i solve this error?!!!
|
|
|
|
|
Make sure that the method that creates the file closes it properly.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
if that method dosn't close it, why there is not any problem on my computer?
|
|
|
|
|
There can be many different reasons why code that is not completely correct may work in one place but not another.
Among possible reason can be different file systems, different memory load, different cpu load, different operating systems.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
You said you're putting this database in the \Windows\System32 folder? Did it occur to you that not every user account has full access to that SYSTEM folder? You might want to pick a better place to put that database before you try and access it, like in the root of the Users profile or in the Temp folder. Even if all you're doing is querying the Access database and not making any changes to it, you still need full read/write permissions to the FOLDER that the .MDB file is in.
And for why it works on your dev machine and not on others - did you develop your app under an Admin account?? Not a good idea - even though most developers do this...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
both computer have the same os , and i login as admin in both computer so it is not for permission .
|
|
|
|
|
Hi,
I have a class which uses async sockets functions (i.e. BeginXXX ).
One of the functions in my class for example is Listen() .
In my callback functions I would like to fire events.
These events could sometimes be used to control the UI.
So what I'm looking for is a way to invoke the events on the calling thread instead of the callback's thread.
I thought of holding a reference to a Control object inside my class.
This reference would be sent to my class through the constructor, and I could then call Invoke() on it.
But what if its not a Control which called my Listen() function?
Is there any way to know which thread is the calling thread, and invoking the events on it?
Thanks in advance,
Shy.
|
|
|
|