|
So why not just wrap the ResourceManager with your own class and have it get the object from ResourceManager, modify it, and return it?? Or am I missing something in your description?
|
|
|
|
|
In a C# Windows Forms app, I have a Panel containing some Labels and Pictureboxes. I have set up delegates at the Panel level to handle MouseEnter and MouseLeave Events. I want something to happen when the user moves the mouse into the Panel and out of the Panel.
However, the Panel MouseEnter and MouseLeave Events are firing when the mouse moves into and out of any of the Pictureboxes and Labels within the Panel. I don't want this behavior. I want them to fire only when the mouse moves into the Panel and out of the Panel.
What am I doing wrong?
Thanks,
Mark
|
|
|
|
|
I'd say you're doing nothing wrong. Because mouse moves above another control it leaves the panel, whether the control is inside or outside the panel.
When mouse leaves the panel, you could check the position of the mouse, is it still inside the panel or not. The same logic can be used in MouseEnter. You can get the position from the Cursor class.
Hope this helps,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I ran a search for a System.Windows.Forms.ToolStrip which matches the width it is given but I was only able to find articles about ToolStripItems of one type or another. If this is a repeat, sorry.
I have a ToolStrip with context which can be resized. I would like the ToolStrip to be as large as it can be. Currently the ToolStrip will take the whole line (row) in the ToolStripContentPanel. If I try to drag the ToolStrip beside a ToolStrip which doesn't take up the whole line, the short one shifts down so that the resizable one can take over the whole line again.
Currently on any client size change of the ToolStrip I set the only item to the MaxItemSize to force the ToolStrip to get as large as it can in the ToolStripContentPanel. This doesn't seem to take into account other strips on the same row.
Although this isn't extremely important to my program's functionality, I'm sure you can understand why this is driving me crazy. If you wouldn't mind helping answer my question I would be very thankful.
How do I create a ToolStrip which will take as much width as it can from the content panel without moving other ToolStrips out of the way?
|
|
|
|
|
I am not sure if I completely understand your question but try this:
With a toolstrip in a toolstrip container, set the "Stretch" property to True. Then toggle that when you want to allow the toolstrip to be resized.
Regards,
Thomas Stockwell
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.
Visit my Blog
|
|
|
|
|
do FileSystemWatcher works with a mapped drive
|
|
|
|
|
Why don't you give it a try?
|
|
|
|
|
The docs state:
"You can create a component to watch files on a local computer,
a network drive, or a remote computer."
I'll let you decide if that means yes or no
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I'll let you decide if that means yes or no
Neither, it means he don't need no stinkin documentation!
led mike
|
|
|
|
|
Hello,
I have an application that I run on my machine with VB2005 .net. Works good.
I take the exe to another machine and the application shuts down. We traced the program to the line:
thisconnection.open() - the application will execute the line but never come back(?). The app will just end.
We think that it is due to permissions or a missing component installed on the 2nd machine.
The program is at this point trying to open an odbc connection to a remote site to get information via sql call. (Again, this will work on the 1st machine without any problems (open, execute and closes just fine the odbc connections).)
Has anyone ever come across this problem or have an idea on a solution?
Sincerely,
Lmnorms1
|
|
|
|
|
lmnorms1 wrote: or a missing component installed on the 2nd machine.
Yes, part of the responsibility of software development is to learn (study, understand, know) about deployment issues. Here are a few of those issues.
* Know how to determine all the components that your application is dependent on.
* Know how to construct an Installer that will install all the components that your application is dependent on.
* Learn how to use Google to find documentation that one can read to learn things that one doesn't know but needs to.
led mike
|
|
|
|
|
Actually, found it. Thank you for the information. The information did help me in building the file properly.
The odbc connection was due to the odbc was not registered. It was built and could be seen in the user dsn but was on showing up in the odbc.ini file in windows. This tells me that it was not registered. Deleted the odbc and set it up again through the ODBC wizard in windows and it worked on the second machine.
Thank you,
Patrick.
|
|
|
|
|
Hi
I need to dial to a modem using RAS and than communicate to a TCP server using tcp client.
If I test RAS and TCP connection in isolation (using sample applications) both are running fine. However when use them both in the order
1. RAS call
2. TCP connection using TCP client.
I am getting following exception:
System.Net.Sockets.SocketException: An error message cannot be displayed because an optional resource assembly containing it cannot be found
at System.Net.Sockets.Socket.ConnectNoCheck()
at System.Net.Sockets.Socket.Connect()
at System.Net.Sockets.TcpClient.Connect()
at System.Net.Sockets.TcpClient.Connect()
at SerialCommunicator.TcpConnection.Connect()
at GosHawkII.Forms.FormMain.ConnectTcpClient()
at GosHawkII.Forms.FormMain.Connect()
at GosHawkII.Forms.FormMain.MenuItemConnect_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at GosHawkII.Program.Main()
Kindly advice what I need to do to achieve the desired results
Thanks in Advance
Manoj Kaushik
|
|
|
|
|
kaushik_Manoj wrote: because an optional resource assembly containing it cannot be found
You need to find out what that assembly is and why it cannot be found
led mike
|
|
|
|
|
hello friends
i am a new user of .net
i have done my exercise of inserting data from vb.net to excel sheet.
my next job is to geting data from excel to windows form in .net
|
|
|
|
|
What have you tried so far? A simple google search should reveal several available techniques.
|
|
|
|
|
I'm probably blind, but doesn't .NET provide a quicksort or other sorting algorithm? Sure, they're a dime a dozen on the web, but I prefer a solution that's built into the framework before reaching elsewhere.
And yes, I know about Array.Sort and its variations. But I want to sort a field in a DataTable and I need a custom comparator.
[edit]Heh. Found this[^] Linq example (second post)
[/edit]
Marc
modified on Wednesday, October 8, 2008 8:47 AM
|
|
|
|
|
|
|
|
Please describe your problem in detail
Cheers!!
Brij
|
|
|
|
|
Hello,
I'd appreciate some suggestions how to solve the problem exposed below.
I apologize in case that's too easy and I cannot see the solution myself.
Thank you in advance.
<code>
using System;
namespace KeepAliveEventsExample
{
/// <summary>
/// How to garbage-collect an instance which is kept alive only by
/// event handlers without removing the handlers explicitly?
///
/// Client runs a procedure. It holds a reference to an
/// object able to raise an event. Inside the method (Run)
/// an instance is created which can subsrcibe to the event.
/// The event handler keeps the subscriber alive even if the subscriber
/// reference is not reachable by the client.
/// In order to allow the garbage collection an "Unregister()" method removes
/// explicitly the event handler.
/// We wish a solution in order to get to the same result without calling any explicit method
/// like Unregister()
/// </summary>
/// <remarks>
/// - No Dispose Pattern
/// - No new Threads
/// </remarks>
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.Run();
Console.WriteLine("RUN FINISHED. PRESS A KEY");
Console.ReadKey();
client = null;
Client.FullCollect("LAST COLLECTION");
Console.WriteLine("FINISHED");
Console.ReadKey();
}
}
/// <summary>
/// A client of publisher / subscriber
/// It keeps a reference to the publisher but not to the subscriber
/// </summary>
/// <remarks>
/// While a reference to the publisher is held, no reference
/// to the subscriber is reachable outside the method "Run()"
/// </remarks>
class Client
{
/// <summary>
/// The client holds a reference to the event publisher
/// </summary>
private ObjectWithEvents obj;
public Client()
{
obj = new ObjectWithEvents();
}
public void Run()
{
Observer _subscriber = new Observer(obj);
//we should see _subscriber reacting
obj.DoSomething(5);
obj.DoSomething(10);
//we would like to eliminate this method
_subscriber.Unregister();
//the subscriber is not reacheable [only through the event in obj]
_subscriber = null;
//here we would like _Subscriber NOT TO REACT without having to do anything
obj.DoSomething(15);
//We would like to be able to collect _Subscriber here
FullCollect("COLLECTION 1");
}
~Client()
{
Console.WriteLine("FINALIZING CLIENT");
}
/// <summary>
/// Try to trigger possible collections in all generations.
/// </summary>
/// <param name="message"></param>
public static void FullCollect(string message)
{
for (int j = 0; j <= GC.MaxGeneration; j++)
{
for (int i = 0; i <= GC.MaxGeneration; i++)
{
GC.Collect(i, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
}
}
Console.WriteLine(message);
}
}
/// <summary>
/// Subscribes to the event of ObjectWithEvents
/// </summary>
/// <remarks>
/// Instances of this object might be kept for the whole application lifetime
/// or just used for performing some operations.
///
/// Implementing the Dispose Pattern is not ok because in the real
/// application this would have a deeper meaning for the user
/// </remarks>
class Observer
{
/// <summary>
/// We can hold a reference to the publisher. This won't generate a problem
/// Also shows that, if we want, we have the publishers available
/// </summary>
ObjectWithEvents _publisher;
public Observer(ObjectWithEvents eventPublisher)
{
_publisher = eventPublisher;
//here we register to the event. This instance is going to
//survive garbage collection because the publisher keeps it alive
//through this handler
_publisher.ValueChanged += new EventDefinition(handler);
}
/// <summary>
/// Unregister the event handler in order to allow GC
/// We would like clients not to have to call this method
/// </summary>
public void Unregister()
{
_publisher.ValueChanged -= new EventDefinition(handler);
}
void handler(object sender, int value)
{
Console.WriteLine("VALUE CHANGED TO: {0}", value);
}
~Observer()
{
Console.WriteLine("FINALIZING SUBSCRIBER");
}
}
/// <summary>
/// Event definition
/// </summary>
/// <param name="sender"></param>
/// <param name="value"></param>
delegate void EventDefinition(object sender, int value);
/// <summary>
/// An object able to raise an event
/// </summary>
/// <remarks>
/// Instances are unaware of subscribers
/// </remarks>
class ObjectWithEvents
{
int _value;
public event EventDefinition ValueChanged;
public void DoSomething(int value)
{
_value = value;
//raise the event.
if (ValueChanged != null)
ValueChanged(this, _value);
}
~ObjectWithEvents()
{
Console.WriteLine("FINALIZING PUBLISHER");
}
}
}
</code>
|
|
|
|
|
Either keep the Unregister, or implement IDisposable with an if(registered) Unregister(); pattern.
If you really, really, really want to get rid of this unregister then I suggest you try to knock up a generic event proxy that uses weak references to refer to the observer, and can unregister and drop itself when the weak reference goes dead.
|
|
|
|
|
Hello,
thank you very much for your answer. The solution with a weak reference was already implemented and it is good to know that it was not only the outcome of a "disperate" programmer (...me). The problem is that some subscribers should survive when they are reacheable directly (not only through the event) so the client should provide that kind of information. Again the client has to think about memory management somehow. It would be perfect to be able to find out where the instance (subscriber) is referenced and check if only the events are keeping it alive. In case of other references the proxy could be restored. But I don't know how (and if it is possible). Anyway you gave me the courage to keep "Unregister" or the like...and this is big value.
|
|
|
|
|
Here is an excellent article about this topic published on codeproject recently: Weak Events in C#[^]
|
|
|
|