|
Corinna: First Name, usually abbreviated (Coco)
John: Ugly Last Name. (One day I'll marry someone just to get a better name.)
|
|
|
|
|
How do you display User Options in a Windows Service.
I know you can stop/start/pause/restart a service.
The is a way to add options to start a windows service. Is there anyway to display these options with out starting the service.
John Ingram
|
|
|
|
|
As you said, you can provide command line arguments in the Services control panel / snap-in.
If you need to configure the options in a different way, you could use a Windows Forms application that either uses registry settings or writes on a .config file (or other configuration file) for the service. You can use the ServiceController class to start, stop, or pause the service programmatically then.
If you want to configure the options while the service is running, you need to use the ServiceController.ExecuteCommand to pass a command identifier. If you need to change more complex options, you can use .NET Remoting over a TCP or HTTP channel.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
I want to add a footer to a datagrid in a windows forms (like the datagrid for asp.net).. How do I go about doing this???
For example I want to display the totals of a columns in the footer..
any help is appreciated!!
|
|
|
|
|
Put a Label control or something similar under the DataGrid . You can update the Label.Text property by aggregating the values in a particular column of your DataGrid . We do that in our app in several cases.
Note that System.Windows.Forms.DataGrid and System.Web.UI.WebControls.DataGrid are very different, both in terms of presentation and logic. The former is a Windows Control that binds differently than the latter, and the latter generates an HTML <table> , which makes having a footer template trivial (since it just uses the <tfoot> tag and adds your rows and columns). They are very different beasts and, IMO, should not be compared.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
My applications use a large number of components (DLLs and EXEs) which previously (using VC6.0) we built using a big build script, and then at the end we ran a program over all the modules which stamped them all with exactly the same version. This made it very easy to tell if a customer has a consistent version of all the components.
Recently I've just created a .NET component that will be released with the rest of the applications. My question is: Is there any way to set the assembly version of an assembly that has already been generated? With the normal Win32 modules I can load then and then modify the resources using the appropriate APIs - but will this work for a .NET component - particularly since the version is part of the strong name of the component?
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
You can use the Win32 resource editing trick for the version of the executable, but not the assembly. Doing this will also invalidate signature if you use signed assemblies (and you should be, especially since it makes versioning easier via config files and policy assemblies, which must be in the GAC and assemblies in the GAC must be signed).
Even if you did change the version and resign the assembly, it still wouldn't be an easy task. You would have to emit an assembly based on a template (the existing assembly).
Frankly, IMO, just implement a policy whereby your developers put the appropriate assembly version into the [assembly: AssembyVersionAttribute] when compiling for the last time. Or, if you have a build master, he or she could either do it (or use a macro to change the AssemblyInfo.cs file (or wherever you put it) to make it quick) and then compile under a release build.
Just remember that the version number in the VersionInfo block of the executable's .rsrc section has little to no bearing on the assembly itself. The AssemblyVersion attribute is what matters, and that's in the MANIFEST for the assembly.
One example: Infragistics commonly updates their assemblies while leaving the AssemblyVersionAttribute with the same value, but changes the executable image's VersionInfo block so that the FileVersion is different. While this makes updating your applications without recompiling easier, it totally screws-over touchless deployment over the Internet because Fusion (the assembly binder) caches assemblies based on their strong name in the temporary assembly cache. Since the assembly version didn't change, the new code isn't always downloaded! (The cases where it is depends on Internet Explorer's cache settings.)
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi i have just added this auto complete feature in my combo box .. When the user leaves the focus from the combobox .. it fires the leave event ... in this event i do this ...
listView.Items[index].Selected = true;
And in the list view selected event i have added some code that get the data from the listview and put them into the appropraite textBoxs or Combox... my problem is this code works just fine only 1 time... the second time it does execute the leave focus event but dosnt set the selected index ... i have no idea why is it doing that
Thanks
DaIn
|
|
|
|
|
Did you try debugging and stepping through the relevent code line by line? Sometimes unexpected exceptions are thrown and handled, or a condition fails. In either case, you should be able to find more information that may help you solve the problem, or provide some additional information to post along with your problem; because, by itself this post doesn't really present any particular problems.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
<br />
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
if ( listView1.SelectedItems.Count > 0 )<br />
{<br />
codeComboBox.Text = listView1.SelectedItems[0].SubItems[0].Text;<br />
modNameTextBox.Text = listView1.SelectedItems[0].SubItems[2].Text;<br />
modAdd1TextBox.Text = listView1.SelectedItems[0].SubItems[3].Text;<br />
modAdd2TextBox.Text = listView1.SelectedItems[0].SubItems[4].Text;<br />
modCityTextBox.Text = listView1.SelectedItems[0].SubItems[5].Text;<br />
modPinTextBox.Text = listView1.SelectedItems[0].SubItems[6].Text;<br />
modPhoneTextBox.Text = listView1.SelectedItems[0].SubItems[7].Text;<br />
modContactPersonTextBox.Text = listView1.SelectedItems[0].SubItems[1].Text;<br />
}<br />
<br />
}<br />
<br />
Thats for the selected index....
<br />
private void codeComboBox_Leave(object sender, System.EventArgs e)<br />
{<br />
ClearSelected();<br />
listView1.Items[index].Selected = true;<br />
}<br />
The index Varaible stores the index of the ID in the listView...
This only seams to execute once ...
|
|
|
|
|
The ComboBox.Leave event is probably not the place you want to be doing this. This event occurs every time your mouse exits the region filled by the ComboBox . Instead, just handle the ComboBox.SelectedIndexChanged .
As far as the problem, if the above suggestion doesn't solve it (indirectly), make sure the ComboBox is throwing the event correctly and step through your code - as I said before - to find where the error is. Also, make sure that your ClearSelected method isn't throwing any exceptions that would cause your code to exit prematurely before the listView1.Items[index].Selected = true is executed.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am creating a web application using dropdownlists in the datagrid.
My question is. I have two dropdownlists in the datagrid. First one select * from sq. That is working Ok.
After the first one is selected the data and pass the argument to Second one
which is retrieved data. Second one does not work. Nothing.
Second query likt select A from sq where name = 'argument'.
Is anyone can help me ?
Thanks
|
|
|
|
|
Unless you're using auto-postback, you'll need to use client-side Javascript to do this. Remember that ASP.NET describes server-side code written in a language that targets the CLR. Only some basic javascript is necessary for some ASP.NET controls to work, but anything in HTML (what ASP.NET generates for most classes) that must change without hitting the server must be performed by client-side script.
So, either set AutoPostBack to true on your first drop-down, or pass all necessary data to both drop-downs and use some javascript and event handlers on the drop-downs (client-side event handlers) to select the appropriate data.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I need to create a combo box control with a custom drop down. Now, before I try to create this from scratch, is there a way to disable the drop down? Thanks for your help
|
|
|
|
|
Disable the dropdown? You mean like a listbox?
|
|
|
|
|
No, I need to disable the drop down box for the combobox control. I need to do this so that I can have a custom drop down appear.
|
|
|
|
|
You could try extending ComboBox , then override WndProc . For the CBN_DROPDOWN notification message (msg id 7), return instead of calling the base.WndProc :
protected override void WndProc(ref Message m)
{
if (m.Msg == 7) return;
base.WndProc(ref m);
} That may stop it, but the documentation for that notification message doesn't mention how to stop it. By not passing the notification message to the ComboBox , though, it shouldn't display the popup window that represents the drop-down. It's worth a shot.
Also, you should consider making your own from scratch. If the above doesn't work, it's often easier making your own controls that trying to change existing ones. Remember that almost every control in System.Windows.Forms is just a wrapper class for their Windows Common Controls equivalent, so the true behavior of the control itself is defined by native code.
If you must make your own, I suggest you download something like .NET Reflector[^] to peer inside how the System.Windows.Forms.ComboBox works for things that aren't apparent in the documentation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi! I'm trying to create a control which is inherited from TextBox and will have OtherControls property where programmer in design-time will pick few controls from the same form.
Question #1: How can i access other controls on the form? Or at least what should i change in my solution (read further)?
I tried to implement UITypeEditor for property OtherControls. UITypeEditor should do next:
1) show a form
2) show a list of controls of MyDerivedTextBox type
3) programmer picks few controls & clicks OK
I managed to achieve goals 1 and 3 , but step 2:
Header of required method in UITypeEditor implementation follows:
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
The problem is, sometime it works, sometime it doesn't. And that's because (LIKE MSDN SAYS) we should not rely on ITypeDescriptorContext because it may return null for its Instance property. That way, i cannot access parent form.
For that reason, next code (in previous mentioned EditValue method) fails with message "Object referrence not set to an instance of an object." (both run-time and design-time):
foreach (object o in ITypeDescriptorContext.Instance.Parent.Container)
Is there any solution?
Thanks!
Sorry for such a long post
Filip Popovic
|
|
|
|
|
First of all, you should be checking for null for each property of your ITypeDescriptorContext before your foreach statement, or put the whole thing in a try-catch to avoid unnecessary errors (though throwing exceptions is far less efficient that performing checks).
Second, you can simplify this by letting the ComponentModel handle this itself. If you specify a design-time visible property that is a Type you are interested in, the designer will automatically provide a drop-down for those types (or at least it's documented that way). This only works for components if I remember correctly, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've already put foreach statement in try/catch block, but that means that if instance property is null i can't examine controls on the form. Imagine yourself using that control, and hopelessly clicking on property expecting UITypeEditor to show up, but nothing happens. And even if instance is not null at that moment and you manage to pick controls, imagine user's face who is using your program when he sees that program is behaving unexpectedly (or does nothing).
I can't use a property that is of MyControl Type, because that way, programmer would be able to pick just one control. And i need that UITypeEditor because programmer should be able to pick an variable number of controls using single property.
Seems like i didn't write original post clearly. Sorry for my bad english.
Thank You, Stewart.
|
|
|
|
|
How often does this actually happen, though, and under what circumstances? I'm sure there probably are instances where it is null , but the documentation doesn't give specifics. The VS.NET designers probably give consistent input while designing. If you're doing this at run-time, you have to make sure that whatever invokes the UITypeEditor provides a proper ITypeDescriptorContext by implementing and using that implementation when invoking the necessary calls.
There just doesn't really seem like any other way to do what you need. The only way to get the instance of your control (or its container, which the ITypeDescriptorContext also has a property for) in UITypeEditor.EditValue is through the ITypeDescriptorContext (or a TypeConverter for that matter). It's the only thing that ties them together.
If your paranoia is getting the best of you (don't worry, it always gets me too), try to evaluate when the Instance or Container properties are null and either avoid those cases or make sure in your implementation that an implementation of that interface is provided (most likely only possible at run-time, since VS.NET and the built-in .NET designers take care of most of the design-time stuff, allowing you to only be a slave to what it provides).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can't tell when does it happen. I forgot to mention that i was working on control about month or two ago. In my case (with my control and FlashTrackBar from MSDN), i was working for a few days, and then for next few the control didn't work (both design-time and run-time). Sometimes it was changing behaviour even during the use of same instance of VS (same day, of course).
I was really mad about this issue. And disappointed when i saw the explanation in MSDN. After few weeks, i've opened the solution and it just worked. The day after, the same error. And so on, hopelessly.
That means that working on a small project might take years, depending on Framework's will!
Unfortunately, i can see no rule to predict whether Instance is null.
However, seems like i'll have to switch to Delphi, because i've already implemented such control in it. Thank you for you help.
Best wishes,
Filip
|
|
|
|
|
Wait, so you you have a problem with either VS.NET's design-time support or some glitch on your machine and it's the framework's fault? Not hardly. I've written a lot of designer support that's used both in design-time and run-time with no problems - ever! And it works on several hundred machines thus far.
You might try reinstalling VS.NET. Besides, if you're talking about Delphi.NET (Delphi targeting the CLR), then you're still using the framework - it doesn't matter which language you use because it all compiles to IL and uses both the BCL assemblies and any other assemblies you reference. There is no difference, except in a few compiler optimizations for the instructions generated here and there.
So, it's pretty evident that VS.NET is at fault here. Uninstall it, clean up your registry and files, and reinstall it. Something's corrupt.
Or switch do Delphi as you said, but just don't go blaming the framework - even though you're obviously having unfortunate problems - for something that's happening on your machine.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Seems like we misunderstood each other. I SAID that JUST controls which use ITypeDescriptorContext.Instance property were behaving badly. NOT ALL CONTROLS. I could still implement designers without problems, but if i wanted to use instance property i would get those messages. Ok?
At that time i was using framework v1.0 and upgraded to v1.1 (if i still remember). Then i had my OS reinstalled (+VS 2003). And i believe that i would still have the same problem, because MSDN still says that there may be some nulls in this interface. Do you suggest me to try again? (now when i reinstalled everything)?
When i blamed Framework, i didn't mean anything bad, it was more like a joke... sounded funny to me at that moment... I'm not a big fan of MS, but i think they did a good job with framework.
No i was not talking about Delphi .NET, because of reason you wrote. I wrote those controls in Delphi 6, so there's no .NET support.
|
|
|
|
|