|
Hi,
I like to change the Startmode of a service in a Windows Forms application using Visual basic.
I tried the following code:
I do not get a error, but the StartMode does not change.
Try
Dim class1 As ManagementClass = New ManagementClass("Win32_Service")
For Each ob As ManagementObject In class1.GetInstances
If ob.GetPropertyValue("Caption").ToString = Me.cbservices.SelectedItem.ToString Then
If ob.GetPropertyValue("StartMode") = "Disabled" Then
ob.SetPropertyValue("StartMode", Me.cbStartMode.Text)
Exit Sub
End If
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Does anybody have an idea?
Thanks in advance for your help!!!!!
Dennis
|
|
|
|
|
Hi,
when getting info from WMI one tends to call ToString to show it;
in VB.NET this isn't even necessary, it will happen implicitly.
When setting info through WMI the type must be correct, StartMode isn't a string, it is a ServiceStartMode value.
Hence:
1. add a reference to System.ServiceProcess
2. do something like (not tested):
ServiceStartMode mode=ServiceStartMode.Parse(Me.cbStartMode.Text)
ob.SetPropertyValue("StartMode", mode)
alternatively add real ServiceStartMode values to the combobox, that would avoid the parsing.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks.
I will try today and let you know the result.
Dennis
|
|
|
|
|
Thanks,
It workes like a charm.
Dennis
|
|
|
|
|
I am using VB6 Sp6 and Crystal Reports 8 in my application ,sql server 2000 in the backend. I am having a problem that if i execute a report i am having problem in the output once in a week but most of the time i am not getting any problems.If i again close and open the report output is correct.I am executing a view from my front end . if i check with query in the view, data is coming fine. In application, data are grouped together by using a Account Number in crystal reports.i am uanble to find any problem can you advice me on this. I need your help.
|
|
|
|
|
Why are you still using VB6 ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Just go to your crystal report report and to file menu there will be a check box that Save Data with report just remove check , problem will be solved
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
I’m working on a project that saves records to a datatable/dataset. I then serialize the dataset to save it, and deserialize to show the records in a datagridview, and I add more records, serialize, deserialize etc etc. – I’m using binary formatting. I added the dataset/datatable from the toolbox and selected “untyped” for the dataset.
I want to print out this table and other text.
Do I need to draw a report using graphics on to a page and then programmatically add the data from the deserialized file, or is there a better way to design and add data to a report? I’ve looked at crystal reports and report viewer and I cannot see how to programmatically add data using them – they both talk about connecting to a SQL or ADO database which mine isn’t.
Any help and/or any tutorials about this would be appreciated.
Regards,
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
First thing is to go get a hammer, now bash your left foot with it, the pain you feel is nothing to what you will feel if you decide to use Crystal Reports. There are a number of threads here discussing reporting tools, none recommend CR.
As you are not even using a database I assume your data requirements are minimal (serializing datasets will very quickly become useless if you have any real volume of data) so depending on the VS version there are report projects/forms you can add. Also there are grid printing articles on CP I believe .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Mycroft,
Yes, I agree with your crystal reports idea!!!! - it definitely is too much for this project. Yes, the data requirements are minimal and yes, I'm not using a database - I put records into a datagrid view and then serialize when finished.
I'm using using VS 2008 full version.
Could you point me in the direction of any articles/help/other threads/sites on this subject please
I'm a beginner hobby programmer and know only a little but feel I've made good progress so far..... I've got this vision where it's possible to placce a piece of blank paper onto a form and then drag n drop the various objects onto it, ready for printing but I'm realising that probably isn't possible. (it's a good idea for an expert to design a class like that...!!!!).
So could you give me some pointers in the direction I need to go....?
Regards,
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
Seems to be plenty of articles[^] here to cover the subject.
|
|
|
|
|
Hi All,
I have a Label and A Picturebox. Picturebox have a image.
Label Backcolor is Transparent.
When i am tring to drag Label in Over of Picturebox. Label Backcolor shows Forms Color.
But i want to get background Image which is in Picture box.
Thanks for help
If you can think then I Can.
|
|
|
|
|
Pick a Panel , set it's backgroundpicture to whatever picture was shown in the PictureBox . Next, drag a label to that panel and set it's backgroundcolor to "Transparent" (webcolor).
There you go, a transparent label
I are Troll
|
|
|
|
|
Thanks Dear,
but my requirement is changing and Draging of Picturebox.
So obviously background will be changed.
So Please give me another idea.
If you can think then I Can.
|
|
|
|
|
Add this to the OnPaint handler of your PictureBox;
public Form1()
{
InitializeComponent();
foreach (Control ctl in this.Controls)
if (ctl is Label)
{
Label lbl = (Label)ctl;
lbl.Visible = false;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
foreach (Control ctl in this.Controls)
if (ctl is Label)
{
Label lbl = (Label)ctl;
e.Graphics.DrawString(
lbl.Text,
lbl.Font,
new SolidBrush(lbl.ForeColor),
lbl.Left - pictureBox1.Left,
lbl.Top - pictureBox1.Top);
}
}
eg_Anubhava wrote: So Please give me another idea.
This hides the labels during runtime, and uses the Paint-handler to write the text onto the forms' canvas
eg_Anubhava wrote: but my requirement is changing and Draging of Picturebox.
The PictureBox itself, or the controls inside it? The Panel that I referred to also has support for drag & drop.
Good luck
"Sometimes glass glitters more than diamonds because it has more to prove"
--Terry Pratchett
|
|
|
|
|
Hello Eddy Vluggen,
Thanks for reply.but
You are trying to create text on picture box.but my concept says show picture in label when i m draging and moving label around picturebox.
If you can think then I Can.
|
|
|
|
|
I'm sorry, but both Label as well as the PictureBox have their limitations. The second solution that I posted removes the Label entirely, and you can't click (or drag) what isn't there.
Unfortunately, I don't know how to achieve the requirements of your concept.
I are Troll
|
|
|
|
|
Hello To All
i am having a hard time here
what i am trying to do it when you check the check box and status is not connected it will display a msg me saying the error messages like Interface is not pluged in
this is my problem i got it to work with the IF but you check the boc get the error boc click on and the check box is checked i dont want it checked if the satus is not connected so i put CheckBox1.Checked = False that worked but now i get the error msgbox 2 times i no why when it taked the check box out it runs the IF code lines agine
Is thare anyway to fix this of some other thing i can google and look up ???
Thanks in advance
Bob
<br />
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged<br />
If Status.Text = "Not Connected" Then<br />
MsgBox("Interface is not pluged in", MsgBoxStyle.OkOnly + vbCritical, "Error")<br />
CheckBox1.Checked = False<br />
<br />
Else<br />
'The Code to Run My Program '<br />
End If<br />
End Sub<br />
|
|
|
|
|
Set a form level flag before you do the check bChecking to true, inside your event code return if the flag = true, this will short circuit the recursive loop. Then the last line (after setting the checkbox) set bChecking to false so it is ready for the next event. Something like the following
Private bool bChecking
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
if bCheckeing then return
bchecking = true
If Status.Text = "Not Connected" Then
MsgBox("Interface is not pluged in", MsgBoxStyle.OkOnly + vbCritical, "Error")
CheckBox1.Checked = False
bchecking = false
Else
'The Code to Run My Program '
End If
End Sub
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycrott
I am pretty sure i got it to work the way i wanted just have to do more testing when i get home tonight
Once agine your help is Greatly appreciated
Thanks
Bob
|
|
|
|
|
Ok i tested it and that part you showd me works perfect now i have a other problem
When click the check box with the device not conectted i get the error msg box and the check do not stay thare that part works good
When click the check box with the device conectted it runs the code
If CheckBox1.Checked Then
NumericUpDown1.Value = CType(CTemp.Text, Integer) + 1
NumericUpDown2.Value = CType(CTemp.Text, Integer) - 1
and it works
But when you click to take the check out of the check box it will not run this code
Else
NumericUpDown1.Value = 0.0
NumericUpDown2.Value = 0.0
phidgetIFK.outputs(0) = False
phidgetIFK.outputs(1) = False
End If
witch it was working before i put the bChecking
Private Sub CheckBox1_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If bChecking Then Return
bChecking = True
If Status.Text = "Not Connected" Then
MsgBox("interface is not connected. Connect USB cable and try agine.", MsgBoxStyle.OkOnly + vbCritical, "Error")
CheckBox1.Checked = False
bChecking = False
Else
If CheckBox1.Checked Then
NumericUpDown1.Value = CType(CTemp.Text, Integer) + 1
NumericUpDown2.Value = CType(CTemp.Text, Integer) - 1
Else
NumericUpDown1.Value = 0.0
NumericUpDown2.Value = 0.0
phidgetIFK.outputs(0) = False
phidgetIFK.outputs(1) = False
End If
End If
End Sub
Thanks for every ones help
|
|
|
|
|
I need to know how to make buttons and other objects move to the center of the form and possibly grow in size when form is maximized and also move back to its position when minimized. Please I need fast response house
|
|
|
|
|
tolmega01 wrote: Please I need fast response house
That is almost certain to slow any replies. If it is that urgent, get your credit card out and visit rentacoder.com
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Look into Docking and Anchor properties of your controls.
There are some articles here on CP that may be useful, try searching.
Delay due to speed demand - I mean you really need to read the forum guidelines before posting!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
i have a form where there is a control to load a word document.
for example on button click opendialogue file to select the document and parse it back to the textbox and then save it to the database..mind you it will be in byte..
please give me a code sample to do this.
thanks
|
|
|
|