|
Maybe you're looking for the RemotingServices.Marshal method? You can pass an instance of the server object to it and all clients will be able to access that object.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
That's exactly what I was looking for. With your help I managed to prove the concept of hooking to my Server EXE.
Cheers.
Chubby..
|
|
|
|
|
Hello everyone
I have some experience in programming C++ and am quite new at C#. Now my question is: Since in C# there aren't pointer like in C++ anymore, how would I implement an aggregation relationship compared to a composition relationship between two classes?
In C++ I would point through a pointer to the other class to implement a aggreation relationship. How do I do this in C#? Could somebody send me a code snipped for let's say the classes 'airplane', 'cockpit' and 'wheel'.
Airplane and cockpit are supposed to represent a composition.
Airplane and wheel are supposed to represent an aggregation.
Thanks for you help in advance!!
Diego
|
|
|
|
|
All objects in C# are "by reference".
So, in its simplest form:
public class Airplane
{
public Cockpit cockpit;
public Wheel[] wheels;
public Airplane()
{
cockpit=new Cockpit();
wheels=new Wheel[] {new Wheel(), new Wheel(), new Wheel(), new Wheel()};
}
}
Now, one would never see that kind of code in real life, I would hope.
Marc
My website
Latest Articles:
Undo/Redo Buffer
Memento Design Pattern
|
|
|
|
|
|
I think it would be kinda difficult to implement true aggregation because of the garbage collected environment. I assume that aggregation implies that the aggregated entity can outlive the aggregating entity.
In Marc's example, if the GC decides to collect an instance of Airplane and the Wheel array is referenced only by that instance, then it will also be GC'ed. Unless of course, you specifically store a reference to that array somewhere else. Again, if someone else is holding on to a reference to cockpit, it won't get GC'ed along with Airplane.
In C++, you're in control of reclaiming memory, so you can accurately delete the Wheels when needed.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
In Marc's example, if the GC decides to collect an instance of Airplane and the Wheel array is referenced only by that instance, then it will also be GC'ed.
If this were the case, why would you want to keep the Wheels? In C++ this would cause a memory leak if you got rid of the Aeroplane (or Airplane if you prefer) without also deleting the Wheels.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
But isn't that the point of aggregation? If the Wheels go off when Airplane goes off, then it's composition.
You're right though, a live Wheels object is of no use if it can be referenced by anyone. Your point also means that for composition to work, you must not return references to inner objects.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi All,
Is it a Bug or what? whenever we write Onvalidating() event of some contorl. It works fine with all controls but toolbar buttons doesn't receive focus so they doesn't trigger the causes validation as well.
Kindly tell me soem way so that these buttons also validate the controls.
Thanx in advance.
sorry for my bad English.
|
|
|
|
|
I ran into this problem sometime ago. I have several MDI children, each with a toolbar. So I added this routine to the base class, and call it as the first thing on th ButtonClick handler for the toolbar.
protected void ValidateFocusedControl()
{
foreach(Control ctl in Controls)
if(ValidateFocusedControlRecursive(ctl))
break;
}
bool ValidateFocusedControlRecursive(Control ctl)
{
if(ctl.Focused)
{
if(ctl.CausesValidation)
{
TextBox txtBox = new TextBox();
txtBox.Bounds = new Rectangle(-100, -100, 1, 1);
txtBox.Parent = ctl.Parent;
txtBox.Focus();
ctl.Focus();
txtBox.Parent = null;
txtBox.Dispose();
}
return true;
}
foreach(Control ctl2 in ctl.Controls)
if(ValidateFocusedControlRecursive(ctl2))
return true;
return false;
}
It basically finds which is the focused control, creates a new TextBox , gives it focus, and sets focus back to the original control.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Oops! sorry about the XML comments. They are the summary , param , and remarks tags.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi,
I got a solution as well which does same...
toolbarButton_Click(...)<br />
{<br />
this.toolbar1.Focus();<br />
if(!this.toolbar1.Focused())<br />
return;<br />
}
isn't it a smaller and better solution? it simply focuses the toolbar and checks that whether it is focuses or not, if it doesnt get focus then it means that focus is still on the control beign validated. Just try it.
sorry for my bad English.
|
|
|
|
|
When you click on a toolbar button, the control that has the focus doesn't lose it, and thus Validating/Validated events are not generated.
My solution goes to great length to ensure that the focus is given back to the control that has it, so that it acts the same as you.
Your solution simply takes focus away from the currently focused control, and doesn't give it back. I did try something similar before getting to my recursive solution, but I don't remember the details.
I took your code and gave it a try, and this is what I came up with:
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
if(!ValidateFocusedControl())
return;
if(e.Button == toolBarButton1)
MessageBox.Show(this, "Button 1 clicked!");
else if(e.Button == toolBarButton2)
MessageBox.Show(this, "Button 2 clicked!");
} The heart of if is that call to ValidateFocusedControl:
protected bool ValidateFocusedControl()
{
bool result = true;
Control ctl = ActiveControl;
toolBar1.Focus();
if(!toolBar1.Focused)
result = false;
ctl.Focus();
return result;
} I gave it a try and it works as expected, even with controls inside tabpages for example.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
its alitle hard to explane what i wont.. but i will try any way.
lets say i got 2 classes:
public class person
{
private string firstname;
private string lastname;
private ArrayList exames; // (or HashTable) contaning Exame objects
public string FirstName
{
get{return firstname;}
set{firstname = value;}
}
public string LastName
{
get{return lastname;}
set{lastname = value;}
}
public ArrayList Exames
{
get(return exames;}
set{exames = value;}
}
}
public Class Exame
{
private string examename;
private int grade;
public string ExameName
{
get{return examename;}
set(examename = value;}
}
public int Grade
{
get{return grade;}
set{grade = value;}
}
}
so far so good..
but now i want to bind the person object to a datagrid. and i want the datagrid to show the next information:
person mike = new person();
mike.FirstName = "mike";
mike.LastName = "james;
mike.Exames.Add(new Exame());
((Exame)mike.Exames[0]).ExameName = "english";
((Exame)mike.Exames[0]).Grade = 100;
mike.Exames.Add(new Exame());
((Exame)mike.Exames[1]).ExameName = "math";
((Exame)mike.Exames[1]).Grade = 90;
in the next way in the grid:
FirstName LastName english math (thouse are the column names)
"mike" "james" 100 90 (the data itself)
(P.S ignore the problem when a persion doesnt have a serten exame.. and all other small error's i know how to overcome them. i just need to know how to show it like this)
|
|
|
|
|
how display line and column on status bar
what do you method to make it
hello everybody ! good luck to you!
|
|
|
|
|
is there anyway to get all the text in a ListBox as an array of strings (string[]) ?
thanks!
|
|
|
|
|
hi
try with this:
string[] s=new string[this.listBox1.Items.Count];
this.listBox1.Items.CopyTo(s,0);
regards,
pubudu
|
|
|
|
|
|
Is there such a thing as a common code module (like a VB Bas File) where a c# application can declare and populate publicly accesible objects / variables ?
I'm trying to implement Remoting. The proxy class that is used is always declared as New. If I get the class from the singleton running server then I want it to know about the application's state ? Ie is the object on the server connected to the database etc...
Any help gratefully received.
Cheers
Chubby..
|
|
|
|
|
there is nothig like .bas in C#
How ever you can make a class with static members and methods to access them throughout application.
sorry for my bad English.
|
|
|
|
|
|
I have a application on client that will connect to server so i want to get Time on Server from Client. How to do that.
|
|
|
|
|
hi,
If the database in the server ,You can simply run a SQL query and get time on that server computer.
"SELECT getdate() as serverdatetime"
If you run above query after connecting to database in the server,then You will receive the Time on the server.
regards,
pubudu.
|
|
|
|
|
That depends entirely on your server. What are you connecting to? A file share?, TCP port?, a server application that your wrote?, NTP service?, Web Service?, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I'm new with c# and i have a question for you :
it's possible to define a module in c# like in vb.net?
I need to define some utility function accessible by any page of my web application; do i need a class for this? and create an instance of that class everytime i need to call someone of the utility function?
There's some other way?
thanks
|
|
|
|