|
sir/madam,
can i check programically before shutting down my computer programically that all the windows are closed(i mean all documents are closed.)
I know how to programically shut down .
Thnaks and regards
Pankaj garg
|
|
|
|
|
You have to check each document to make sure it is closed. You can check if any forms in the application is open.
Use
Application.OpenForms.Count
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
|
The following code describes that we can get the current date and time format of our machine
System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat
can i please get to know how to change the current date time format of our machine
Thanks and Regards
Pankaj garg
|
|
|
|
|
You don't, unless you're writing a system utility. This will change the setting system-wide, immediately affecting all other applications running on the machine at that time and in the future.
Is this really what you want to do?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
you must use Date.Now to get the machine local time
|
|
|
|
|
Sir/Madam,
can i please get to know the basic difference between the parameterfield and parameterfields
Both the classes come under the CrystalDecisions.Shared , the base framework class
Thanks and regards
Pankaj garg
|
|
|
|
|
Like all other classes with an "s" at the end, one usually represents a collection of the other. The ParameterFields class represents a collection of ParameterField objects.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want to write a code for automatic shutdown of computer at certain time in VB.NEt . Any pointers ? Thanks in advance
|
|
|
|
|
|
|
I've been messing around with CodeDom lately in an attempt to generate some data handling code for my latest project and run into a problem that has me stumped. It seems that when generating an If statement in VB .NET and calling the IdentityInequality operator you get different results when you would expect the operator to act in a consistent manner.
I have the following snippet of code:
Dim csIfStatement As CodeConditionStatement<br />
Dim csDBNullIfStatement As CodeConditionStatement<br />
<br />
...<br />
<br />
csIfStatement = New CodeConditionStatement(New CodeBinaryOperatorExpression(New CodeVariableReferenceExpression("drData"), CodeBinaryOperatorType.IdentityInequality, New CodePrimitiveExpression(Nothing)))<br />
<br />
For Each row As DataRow In Me._Columns.Rows<br />
strColumnName = row("COLUMN_NAME").ToString()<br />
<br />
csDBNullIfStatement = New CodeConditionStatement(New CodeBinaryOperatorExpression(New CodeMethodInvokeExpression(New CodeVariableReferenceExpression("drData"), "Item", New CodePrimitiveExpression(strColumnName)), CodeBinaryOperatorType.IdentityInequality, New CodePropertyReferenceExpression(New CodeTypeReferenceExpression("DBNull"), "Value")))<br />
<br />
csDBNullIfStatement.TrueStatements.Add(New CodeAssignStatement(New CodeVariableReferenceExpression("_" + strColumnName), New CodeMethodInvokeExpression(New CodeVariableReferenceExpression("drData"), "Item", New CodePrimitiveExpression(strColumnName))))<br />
<br />
csIfStatement.TrueStatements.Add(csDBNullIfStatement)<br />
Next<br />
<br />
cmMethod.Statements.Add(csIfStatement)<br />
<br />
...
Which gives me the following output:
If (Not (drData) Is Nothing) Then<br />
If (drData.Item("JobID") <> DBNull.Value) Then<br />
_JobID = drData.Item("JobID")<br />
End If<br />
End If
When I really want:
If (Not (drData) Is Nothing) Then<br />
If (Not drData.Item("JobID") Is DBNull.Value) Then<br />
_JobID = drData.Item("JobID")<br />
End If<br />
End If
Has anyone been in the same situation or know how I get around this? I'm sure I'm just too much of a noob at this and have missed something very basic.
Thanks
Simon
|
|
|
|
|
I may be wrong here, because I don't write this kind of code, but IIRC, the Is operator is a VB.NET shortcut for comparing the type references of two objects. I think you're missing getting the CodeTypeReference of both operands.
My confidence level on this answer is about 10%, so feel free to ignore this! :->
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave
Thanks for this.
I'll give it a go and see how it reacts, I think I might still have an issue though because when I change the operator from IdentityInEquality to IdentityEquality I do get an Is instead of an =. So the problem just seems to be isolated to the IdentityInEquality operator. I was thinking that it might have something to do with there not being a ValueInequality operator, maybe someone tried to get funky and combine the two with some smarts??
Simon
-- modified at 22:42 Sunday 4th March, 2007
|
|
|
|
|
I think you were on the right track with this one. Now all you have to do is get a Not operator in front of the binary expression and you should be OK.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave
I know I can just "hard code" it in the generation methods to give me the VB syntax I want, but I was wondering if there was an answer that would allow me to port it to C# if I needed to in the future without having to recode that part... The more I look at it it seems to be a Microsoft quirk that you just have to put up with when you use their stuff.
Thanks for trying
Simon
|
|
|
|
|
Just an update, I tried the above suggestion and have had no luck. The generated code now comes out as:
<br />
If (drData.Item("JobID").GetType <> GetType(DBNull)) Then<br />
_JobID = drData.Item("JobID")<br />
End If
When it should be:
If (Not drData.Item("JobID").GetType Is GetType(DBNull)) Then<br />
_JobID = drData.Item("JobID")<br />
End If
So no luck with that one... Thanks for the attempt though, thought you might have been on the right track there.
Simon
|
|
|
|
|
Hi,
Is it possible in VB.net to add a usercontrol onto a form that is set as IsMDIContainer? I can successfully add the control onto the MDI form but am having problems showing Child forms when the user clicks a button on the usercontrol.
The below code is run when the menu's button is clicked, basically creates and instance of the form, sets the size equal to a size area where I want child forms to take up, shows the form and brings it to front.
Private Sub Menu1_ButtonClicked(ByVal Index As Integer) Handles Menu1.ButtonClicked
Select Case Index
Case 1
Dim objForm As New frmClients
objForm.Size = Menu1.FormArea
objForm.Show()
objForm.BringToFront()
End Select
End Sub
In the New() method of the form being shown is the following code which assigns the mdiparent window property and adds the form into a collection so it does not go out of scope.
Me.MdiParent = Application.MainWindow
Application.Forms.Add(Me)
There isn't an issue with child forms showing as the application worked ok before, it is only since adding the usercontrol and trying to load forms via this control.
Cheers
|
|
|
|
|
Your usercontrol shouldn't be concerned with creating new forms and assigning them to a parent. This would tie your usercontrol to the form, and application, to the point where you couldn't possibly use the control in any other form or application.
There is no problem with putting a usercontrol on an MDIParent form, so long as you understand how an MDIParent form renders it's contents. In the client area of an MDIParent, it's the same as any other form. You drop controls on it and they'll show up. But, there is a control that takes up the entire client area of an MDIParent form, called the MdiClient control. This control is what your MDIChild forms get shown by.
The MdiClient control is normally sitting behind all the other controls on the MDIParent form. It'll appear as if all of your MDIParent controls are hovering over all of your MDIChild forms.
Now, as far as manage MDIChildren, the parent form should be doing that, not your usercontrol. You control should be written to expose an event that the MDIParent subscribes to and is told that a new MDIChild form should be created. Your MDIParent then has the option of ignoring this request or following through with it. Then, creating the child form is easy:
Dim newChild As New Form2
newChild.MdiParent = Me
newChild.Show()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
Thanks for your reply.
My usercontrol doesn't actually create and load forms. It raises an event that passes and index representing the button that is clicked on the control. My problem seems to be that the usercontrol seems to stay at front and the forms that get loaded are hidden behind. After clicking the button which loads a form I hid the usercontrol and I could then see the form?
In the code I do try to bring the loaded form to front - objForm.BringToFront() but this doesn't seem to work.
Does anything obvious stand out in my logic?
Thanks again for your time.
Regards
David
;);)
|
|
|
|
|
You missed the point of my reply entirely. Your MDIChild IS in front...of all other MdiChildren.
The problem is that all MDIChildren are rendered by the MdiClient control, which is BEHIND your UserControl. Your MdiParent has TWO controls on it, not one. The MdiClient control (which hold all of your MdiChild forms) and your UserControl. Calling BringToFont on the MDIChild form only brings it to the front of the stack of MDIChild forms INSIDE the MdiClient control.
You have to call BringToFront on the MdiClient control, or call SendToBack on your UserControl. But, that'll make your UserControl appear to disappear, when really, it's behind the MdiClient control.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave, will try to come up with a better solution than creating a user control for my purposes.
Thanks again for your time.
Regards
David
|
|
|
|
|
sir/madam,
i have data in the table and database(MS-Access) .Can i send the data into excel sheet.
please help.
thanks and regards
pankaj garg
|
|
|
|
|
Did you try the DTS Wizard?
|
|
|
|
|
just select the tabel tht u want in excel and u can see a icon called office links there will be 2 optons for word and excel just select excel
the total datas in that selectd tabel will display in excel
Cheers
Prakash
|
|
|
|