|
Hello,
I have a DateTimePicker control with check boxes on a form (well, several, but the behavior is the same for all.)
In design time, I set the Checked property to false. And they appear without the check.
When I run the app, the control is drawn checked, altough looking in the debugger, the Checked property is false. Once I start clicking on the checkbox, it checks and unchecks correctly.
So, we have it with Checked==false and check drawn. If I click on the checkbox, the check is cleared, Checked is still false, and I get no ValueChanged event. If I click again, everything works as expected (Checked set to true , and ValueChanged event).
Is it a bug? or am I missing something?
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi all,
Is Window messaging by using the RegisterWindow MEssage API in C# a good way
to perform messaging between IPC ? How is it compared to IPC by MSMQ and .net remoting ? Is RegisteredWindow Message supported on Window 98 and Window ME also ?
Thanks
Patrick
|
|
|
|
|
pyhtang1 wrote:
Is RegisteredWindow Message supported on Window 98 and Window ME also ?
Check out the documentation for the function in the MSDN Library[^] for questions like these. In this case - if you understand what RegisterWindowMessage does - the answer should be obvious. You can't send unique messages without registering them.
What's best? Whatever is best for your situation. If you're communicating between two managed applications, I would not recommend Windows messaging. Use .NET Remoting with a TcpChannel . In .NET 2.0 they are also adding an IpcChannel which, IIRC, uses named pipes. Both are pretty fast, though there's a little extra overhead for using a TcpChannel . You could even create your own channel like the IpcChannel now - .NET Remoting is extensible enough.
If this was a named application, you could use Windows messaging, global memory, DDE, and anything else you can think of (you can use these in .NET, but often the overhead of P/Invoking what's required and marshaling isn't worth the trouble; .NET Remoting provides a rich RPC experience, too).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
How do I pass a form-controller instantiated in my form to a user-defined control?
|
|
|
|
|
What is a form controller? Maybe you should clarify your question a little bit.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi,
I would like to know in C# : how to detect that I have a break or connection with the network?
Best Regards
youssef
|
|
|
|
|
As we've discussed in this board before, you should P/Invoke any one of various native functions like InternetCheckConnection :
public bool Connected
{
get { return InternetCheckConnection("http://www.codeproject.com", 0, 0); }
}
[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern bool InternetCheckConnection(string url, int flags, int reserved); You can also use this and similar functions defined in the WinInet library to force connections.
Look-up that function in the MSDN Library[^] and you'll find more options with other similar functions.
The pure .NET-way is just to request a network resource and handle SocketException or WebException (often times the SocketException is an inner-exception).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I would like to change the UK langage by FRENCH langage.
How can I do that ?
Best Regards
youssef
|
|
|
|
|
youssef wrote:
I would like to change the UK langage by FRENCH langage.
How can I do that ?
While there are articles here on Code Project, I would suggest you read Globalizing and Localizing Applications[^] within MSDN. This should get you started, if you have further questions, post again.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have an usercontrol with some controls and a hosting windows-form application which includes that usercontrol.
I know how to handle the events in the usercontrol from the hosting application. I want to know if there is any way to handle events in the hosting application from the usercontrol?
Please let me know
|
|
|
|
|
Not unless the parent container hosting your control forwards you the events. Your user control should not know anything about the container that holds it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am trying to write a user control and I need to capture the arrow keys. The form I am testing on does not have KeyPreview on, but when my control has focus and I press the arrow keys it changes focus to the appropriate control on the form.
How can I capture the arrow keys?
After further investigation, if I press the key twice the control "sees" the keyboard press ???!!!!???
Thanks,
Richard
|
|
|
|
|
OK, I have a control, Foo. This class has an object, FooOptions, as a property (named Options). On FooOptions there is a integer property, Number.
I want to make FooOptions editable from the designer, when a Foo control is planted on a form. In particular, I want to pop up a dialog box when the user double-clicks on Options. So I wrote a form, FooOptionsUIEditor, which holds a PropertyGrid (which gets an instance of FooOptions), and gets launched from FooOptionsEditor, which is derived from UITypeEditor. I set the Editor attribute on the Foo.Options property. I also wrote FooOptionsSerializer, which is devired from CodeDomSerializer, and used that for FooOptions's DesignerSerializer attribute. Finally, on Foo.Options, I set the DesignerSerializationVisibility attribute to Content.
What this should do, I expect, is give me a form when I double click on Options in the designer, where I can edit Number. When I close the dialog, it should mark the parent form (which holds an instance of Foo) as editted, and allow me to Save, which would trigger the serializer and place some code in the Windows Forms Designer generated code area on said parent form.
And in fact, everything works-- except that the parent form is not getting marked as editted. My Foo.ShouldSerializeOptions() method is getting called (a lot), and I'm returning true. If I change some other property, either on Foo or on the parent form containing Foo, then the parent form is marked as editted, and I can save, and my serializer works perfectly. My changes are lost if I just edit the FooOptions and close the form in the designer. However, if I edit the FooOptions twice from the designer, the first changes show up, so it's persisted in memory alright.
I thought that maybe there was some trouble with the fact that I was editting FooOptions in a modal form, so I rewrote it to edit with a drop-down. That didn't work. I tested a drop-down with a simple string property on Foo, and that worked. So then I tested a simple string property on Foo, editted with a form, and that worked to. I have to conclude that the fact that FooOptions is an object is causing some kind of trouble.
Incidently, on Foo, Options only has a getter, no setter. But if I add a setter, the behavior doesn't seem to change.
How do I get the parent form to be marked as editted?
This is the first time I've worked with designers and customizing designer behavior, so please, any tips are welcome, no matter how simple. I've been banging my head against the wall for 3 days now.
|
|
|
|
|
object88 wrote:
This is the first time I've worked with designers and customizing designer behavior, so please, any tips are welcome, no matter how simple.
You've obviously done your research.
While it may not make a difference, be sure that you're calling GetService on the IServiceProvider instance passed to your UITypeEditor.EditValue override, and get the IWindowsFormsEditorService in order to call ShowDialog to open your form. That ensures that your dialog is parented properly with the designer and may trigger the results you're looking for. I haven't spent a lot of time in this area of the component designer IL (which you can view with ildasm.exe straight from the SDK, or use a decompiler like .NET Reflector), so I'm not totally sure.
Typically when you want to edit "sub-options", one would either extend ExpandableObjectConverter or just derive from TypeConverter and implement the GetProperties and GetPropertiesSupported . In this case - if you're using a struct - you'll also want to implement CreateInstance and GetCreateInstanceSupported so that you're struct gets recreated the CodeDomSerializer picks up the change.
I'm guess that in your case, such a simple option editor isn't desireable. It would seem that the problem is that the serializer isn't signaling to the designer host (VS.NET) that the file has changed. You may want to query for the IComponentChangeService (as you should with the IWindowsFormsEditorService as I mentioned above) and call OnComponentChanged with the necessary parameters when you're finished. This will signal the designer host that your component has changed (or perhaps that a single property has changed, depending on how you call OnComponentChanged ) and it should then serialize your code correctly.
The specially named ShouldSerializerPropertyNames are really for when non-default values are assigned to a property. It really wasn't designed for changes in the component model like this.
HTH
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the quick reply. I am using the IWindowsFormEditorService retrieved from the passed-in provider in EditValue to display my dialog.
So if I extend ExpandableObjectConverter or derive from TypeConverter, I set that on my FooOptions class with the TypeConverter attribute? I didn't mention it before, but I actually have a class that does that, except only to override the "ConvertTo" method when requesting a string, so that I don't get the class name in the designer. I'll try toying with the GetProperties and GetPropertiesSupported methods.
Failing that, I'll check out the IComponentChangeService stuff. Seems like there's a wealth of service stuff in there that I haven't discovered yet.
I won't worry about ShouldSerializeXXX.
Thanks for the help! I'll be sure to report back when I find out anything.
|
|
|
|
|
WOOOOHOOOO!!! Calling IComponentChangeService.OnComponentChanging and .OnComponentChanged did the trick. After I make the changes in the designer, the changes in the code are immediately reflected in the generated code area. In my code, I just passed in null for the MemberDescriptor, oldValue, and newValue... is there any advantage to calling them out explicitely?
(As an aside, the TypeConverter stuff didn't do anything, but you suspected that. Alternately, I just didn't twiddle the right bits.)
Thanks you! This problem has been driving me farking nuts.
|
|
|
|
|
Glad to hear it!
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
In this case you're not really using the conversion methods to convert from one type to another, but to allow the designer (in this case, the PropertyGrid) to edit properties of your type and - for value types - to create a new instance in order to set those properties.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
This seems to work fine in a Windows Form application but fails in a Class Library, why?
My App.config says:
<configuration>
<appsettings>
<add key="hypSOAPMaxJobsPerMailer" value="10">
if I issue a ConfigurationSettings.AppSettings.HasKeys() in a Class Library it tells me FALSE, but in a windows form app it tells me TRUE!!?
What am I missing?
Guillermo Jimenez
|
|
|
|
|
Sorry, this is the content of the App.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="hypSOAPMaxJobsPerMailer" value="10" />
</appSettings>
</configuration>
|
|
|
|
|
Because the executable loader only associates .config files for the AppDomain for applications (.exe), not libraries (.dll; this is documented). A library will use the settings specified for an application's .config file in which the library is loaded and mapped.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi, i have a drawing using GDI+ in a function Drawpicture(Graphics a) n I called it in
protected override void OnPaint(PaintEventArgs e)
{
Drawpicture(e.Graphics)
}
However, i want it to be on the picturebox. i tried calling it like this:
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Drawpicture(e.Graphics)
}
but it won't work. Plz help. thanks
Chris
|
|
|
|
|
When overriding OnEventName methods you should almost always call base.OnEventName name to make sure that the events gets fired. If you don't, even handlers are called and other operations that may be pertinent to the operation won't run (your override is called in lieu of the member you're overriding; the base member will not be called automatically).
nuttynibbles1984 wrote:
but it won't work. Plz help. thanks
You're going to have to be a little more clear than that. Are you getting exceptions? Is your method even being called (i.e., you should debug your code first)? Is it called but nothing appears?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi, erm there are no error. currently i'm drawing it directly onto the form. i only draw it onto the form when i click a button.
//initially,set picturebox enable properties as false;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if(pictureBox.Enabled == true)
{
Drawpicture(e.Graphics);
}
}
private void Drawpicture(Graphics a)
{
Graphics myGraphics = CreateGraphics();
....
}
private void button2_Click(object sender, System.EventArgs e)
{
pictureBox.Enabled = true;
}
By doing this, i display my drawing onto the form when the button is click. However, i want to display it into the pictureBox when the button is click. How should i do that.
Chris
|
|
|
|
|