|
Heres the names I will use.
Classes- ParentForm - The MDI Parent
- ChildFormA - One of the child forms
- ChildFormB - Another child form
- ChildFormC - The last child form
- DataA - Data class for ChildFormA
- DataB - Data class for ChildFormB
- DataC - Data class for ChildFormC
Class instances stored in ParentForm class- childA - ChildFormA
- childB - ChildFormB
- childC - ChildFormC
Now a little setup
In ParentForm
public void SendToChildA(DataA data)
{
childA.Data = data;
childA.DataSent();
} Do similar for the other children (B and C)
Now in each of the ChildForm s create a Data property which is of the same type as the class associated with it. Also create a method called DataSent which will actually do the processing of the data for the child form.
Now when you want to send data from one child form to another you call the appropriate method on the parent.
....
ParentForm parent = this.Parent as ParentForm;
DataB data = new DataB();
parent.SendToChildB(data);
.... If you wanted to truly adopt .NET practices you would replace the DataSent method and Data properties on the client with events; but for a quick example this works. I'll leave switching to an event as an exercise for you, its not too difficult
HTH,
James
Simplicity Rules!
|
|
|
|
|
Thank you very much I apreciate you help!
|
|
|
|
|
Anyone know how to find the control I am currently over without cycling through each one?
ie. Control ctrl = this.hittest(x,y);
cant find hit test anywhere.
thanks
|
|
|
|
|
Check something like this:
protected override void OnMouseOver(System.Windows.Form.MouseEventArgs mea)
{
mea.<code>[SomeMethod()]</code>
}
Sorry, not at home(with .NET Framework) to check the exact value, hope this will lead you in the right direction.
Nick Parker
J
This is a non-Calculus course as long as you know things like line integrals and surface integrals...
|
|
|
|
|
|
Thanks, GetChildAtPoint() works perfectly.. except for these two problems:
1) it takes relative x and y to that control's clientarea. so this.GetChildAtPoint(10,10) is very different from txtBlah.GetChildAtPoint(10,10)... which leads to my next problem:
2) get child only gets one child down. I would rather have this.GetChildAtPoint(x,y) get the control inside of the groupbox at x,y and not the groupbox. code to get only the second layer looks like this:
Control m_ctrl = this.GetChildAtPoint(new System.Drawing.Point( e.X, e.Y));<br />
Control m_subCtrl = m_ctrl.GetChildAtPoint(new System.Drawing.Point( e.X - m_ctrl.Left, e.Y - m_ctrl.Top ));<br />
any ideas (without recursion, please )
|
|
|
|
|
Point pt = new Point(x, y);
Control parent = this;
Control child = parent.GetChildAtPoint(pt);
while (null != child)
{
pt = parent.PointToScreen(pt);
pt = child.PointToClient(pt);
parent = child;
child = parent.GetChildAtPoint(pt);
}
BTW, If there is a functional equiv. to the MapWindowPoints API, I am all ears...
|
|
|
|
|
A slight improvement to reduce the number of point mappings...
Point pt = new Point(x, y);
Control parent = this;
Control child = parent.GetChildAtPoint(pt);
if (null != child)
{
pt = parent.PointToScreen(pt);
do
{
parent = child;
child = parent.GetChildAtPoint(parent.PointToClient(pt));
} while (null != child);
}
|
|
|
|
|
if (c_urwondering)<br />
{
I have a form with three tabs in a tabcontrol and many controls inside each tab. even controls inside groupboxes in each tab. many.
this form represents a scrollable row in a recordset. it has a vertical scrollbar on the right.
I attach:
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Dialog_MouseWheel);
i want to only allow scrolling when the mouse is not on data driven controls. so scroll when over a label, but not a combobox; inside a groupbox, but not inside a checkbox in a groupbox. etc
}
|
|
|
|
|
I use this connection string to connect to database:
connString=@"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=mypass;Data Source=..\..\Tennis.mdb;Jet OLEDB:System Database=E:\Program Files\Microsoft Office\Office\System.mdw" ;
but ecxeption thrown:
---------------------------
---------------------------
System.Data.OleDb.OleDbException: Not a valid account name or password.
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at Tennis.MainForm..ctor() in f:\visual studio projects\projectc#\tennis\mainform1.cs:line 65
---------------------------
OK
---------------------------
Any suggestion?!!!
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
1. All of the examples I have seen using "System database=" spell it with a lower-case "database" as in "System database=" not "System Database=". I really don't know if this matters or not.
2. Are you using a general password protected database, or a user-level secure database? If you are using a general password protected database, the connection string magic is ";Database Password=mypass;".
Regards
|
|
|
|
|
Scratch #1, I eliminated it as a potential problem...
|
|
|
|
|
Thanks Neil,
The Magic WAS the ";Database Password=password;" (with a ;Jet OLEDB before it
I feel relifed.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Any time...
Somehow I originally had the notion that you were attempting user-level security...
Regards
|
|
|
|
|
I am using Visual Studio 7.0 to begin to learn Socket programming. Unfortunatley the System.Net and System.Net.Sockets namespaces do not exist. When I compile my project I get the following error.
"The type or namespace name 'Net' does not exist in the class or namespace 'System' (are you missing an assembly reference?)"
Now Ive been looking on the net for a solutions to this problem and every one says to add a refrence to the System.Net.dll on my machine. Ive looked and looked but the System.Net.dll does not exist. Is there anywhere I could download it?
Thanks
|
|
|
|
|
Have you made sure you installed the .NET framework.
I had this problem once and I had to uninstall the Framework and reinstall and everything worked fine.
|
|
|
|
|
You're right, it doesn't exist; its part of System.dll which declares quite a few other types. Ensure that it is properly referenced in your project (it is by default but you could have accidentally removed it).
James
Simplicity Rules!
|
|
|
|
|
Just to make sure I added a refrence to every .NET dll to the project including System and there is still no System.Net namespace.
Is there a place where I could download it?
Thanks
|
|
|
|
|
System.dll is where the System.Net namespace is declared (I checked with Anakrino) so that means you have a spelling error, or your .NET install is corrupt
I don't think there is any place that has that single dll online, my System.dll is 1.10MB and was last modified January 5th, 2002; check yours to make sure it is the same. You can find it in %WINDIR%\Microsoft.NET\Framework\%DOTNET_VERSION%\
HTH,
James
Simplicity Rules!
|
|
|
|
|
Try manually adding the reference to the system.dll through the Add Reference menu item in the solution explorer (rt click on the reference tab or thru project menu). I assumed you had vs.net installation.
I ran into same issue couple of days back, it worked for me.
Hope this helps
Kannan
I am not here to accommodate the requirements of mass hysteria.
|
|
|
|
|
Hi All,
I thought I had finally figured out cookies and have now run into another problem.
I have 2 pages which both add data to a cookie as follows
**********Page 1**********
HttpContext.Current.Response.Cookies["MyCookie"]["Session"]= Session.SessionID;
HttpContext.Current.Response.Cookies["MyCookie"]["MyName"] = "Gavin";
HttpContext.Current.Response.Cookies["MyCookie"]["MyDrink"] = "Beer";
**********Page 2**********
HttpContext.Current.Response.Cookies["MyCookie"]["MyFood"]= "Pizza";
HttpContext.Current.Response.Cookies["MyCookie"]["MyTeam"] = "Liverpool";
**************************
After Page 1 as I enter Page 2 my 3 Cookie Keys (Session, MyName & MyDrink) are all fine, but as I try and add the 2 new Keys my cookie loses the first 3?
I hope everyone understood that one
Can someone explain why this is and how do I stop it.
I am looking at saving about 100 different things in this cookie so I don't really want to rewrite all the keys on every page.
Thanks,
Gavin
|
|
|
|
|
It appears you're right, the cookies are reset after each round trip; but the more I thought about it the more it made sense. A cookie is just text that is passed back and forth between the server and the client. And if memory serves correctly to not pass the cookie back to the client tells the client to delete the cookie.
One thing you can do to preserve the cookies is to loop through the list and re-add the cookie to the response.
for( int i = 0; i < Request.Cookies.Count; i++ )<br />
{<br />
Response.Cookies.Add(Request.Cookies[i]);<br />
}
This is something I think ASP did for you, but I don't remember off hand.
Now, to save you from bickering from your users; PLEASE don't use cookies to store that much data Its okay to store a few bits, but you are limited in your cookie space by most browsers; and that is more traffic that goes to the server and back to the client.
ASP.NET's session object is now webfarm friendly with use of either an out-of-proc server or using SQL Server as the session state holder.
With that said you're going to need a way to store your data, if you can't use a database to store the data then at least put all your data in a memory stream (or some other form so it is one contigous block), compress it, then base64 encode it and store that in the cookie. The space you save will make your users and your provider happy
Good Luck,
James
Simplicity Rules!
|
|
|
|
|
Okay in original ASp I was told to never store so much data in a Session Object and to either use Cookies or a Database.
Now I'm being told not to use Cookies for this much data?
You just can't win, at least it makes sense now though, I will use my SQL database instead.
Cheers,
Gavin
PS: Thanks for the help
|
|
|
|
|
Original ASP had the problem where the session object wasn't webfarm friendly, so you had major scalability issues involved. With ASP.NET you can use a SQL Server Database to store the session data or an out-of-proc server (exe) on the network to host it; so it is webfarm friendly and thus scales pretty well.
Now of course session data is going to take up RAM on the server the session is stored on; but how much data is really being taken up per session? Probably not enough to make it matter.
James
Simplicity Rules!
|
|
|
|
|
Hi to all...
Does anybody knows how to center the child window (Main Form View) in SDI application??? I've tried tried and tried, but still cannot get the child form to be centralized.
Please help or give a little advice / pointers how to get round this. Thanks.
Rdgs, Ben
|
|
|
|