|
hi i am a student working on my final year project i hav dissabled print option from the file menu using a com addin but when i press ctrl + P the print option comes up again. some one help me
and i want only my addin to work in word i want to dissable all other addins can some one guide me
chandrashekar
|
|
|
|
|
Maybe Dave can double check me but if you assign the key sequence to something else like form1.focus then it might bypass the print function.
1. Out of clutter, find simplicity.
2. From discord, find harmony.
3. In the middle of difficulty lies opportunity.
Albert Einstein
three rules of work
|
|
|
|
|
Sorry, I don't do Office automation.
But, it doesn't sound like the right idea.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello, is there anyone know how to auto-fill a textbox?
I have 4 textbox, first_name, middle_name, last_name, and full_name, I want the full_name textbox to be auto-filled when the first_name, middle_name, and last_name entered, so user doesn't need to fill in the full_name textbox. any idea to do this?
thanks.
Lisa
|
|
|
|
|
Handle the TextChanged events of the 3 text boxes, you could even do this with a single function. Combine the contents of the 3 text boxes and place the result in the FullName textbox.
Private Sub NameTextBoxesChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstName.TextChanged, MiddleName.TextChanged, LastName.TextChanged
FullName.Text = LastName.Text & ", " & FirstName.Text & " " & MiddleName.Text
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In VB.Net this should work (code is untested):
<br />
Private Sub Textbox_TextChanged(Sender as Object, e as EventArgs) Handles first_name.TextChanged, middle_name.TextChanged, last_name.TextChanged<br />
<br />
full_name.Text = first_name.Text & " " & middle_name.Text & " " & last_name.Text<br />
<br />
End Sub<br />
|
|
|
|
|
Ummm... and this is different from what I posted, how?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
:-OSomehow I missed your post. Sorry about that.
|
|
|
|
|
I've been trying to attach a SQlReader and SQLCommand to the same SQLConnection and i am getting the error that SqlConnection is already open.
I think that we can attach only one object to the connection at a time, correct me if i am wrong.
|
|
|
|
|
Nope, you're right. You can only attach one object to the connection at a time. But there is nothing stopping you from creating a second connection to the same database and using that with your other object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
But then is'nt it utilising extra resources. What is connection pooling for then? I don't understand why we can only attach one object with a connection. Then it means that if i have to query the same table again using a different object(SQLReader) then for that i have to open a new connection, despite of the fact that a connection is already open on that database, putting extra load on sql server(it dosen't sound much of an issue when we are using in a simple data application, but it is a big issue with a erp model based application).
I am using vb 2005 beta. don't u think that in the next version they should allow multiple objects on sqlconnection or am i wrong?
|
|
|
|
|
Connection pooling is for recycling connection objects very rapdily. For example, when hundreds or thousands of users are hitting your data-driven web page, the connection objects are constantly being recycled in the pool, each making a single call to the database.
I don't know the reason behind why you can only attach one reader to a connection, maybe it's because of something to do with server-side cursors, who knows. But, best practice, unless absolutely necessary, is to open a connection, use it for whatever query you need, then close it and detroy the objects. This applies even if you have to open a new connection for a second simultaneous query.
You're really not putting that much of an extra load on the server. Going back to the website example, if connection pooling can open and close connections at a rate of thousands per second, how much of a load are you really puting on the server by opening a second connection in your application?
But, leaving a connection open DOES consume resources on the server. How many users are going to be hitting the database all at once? How much RAM is in the SQL server? How many connection licenses does your server have? Starting to get the picture?
And no, I don't think they should implement this feature to allow multiple command objects access to the same connection object. I think it'll promote bad practices, like people opening a global connection for the life of an application, which is a very bad idea!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi,
How can you close a form form within another one.
|
|
|
|
|
You can only do this if the current form has a reference to the form you want to close. If that's the case, all you have to do is call its Close() method.
What exactly are you trying to do with this?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have one main form and then a settings form. When i change the settings i need to close the main form as the settings won't take effect till i restart the program. How to I create a reference to the form i want to close
|
|
|
|
|
it depends on the scenrio you are using. like if setting form is the dialog form then on completion it will go to your main form and you can check the settings changed or not. If it is not the dialog then pass the main form reference to child form and on changing close the form by using this reference.
|
|
|
|
|
I've been writing code for 27 years and I can't follow what you just wrote.
There is no need to pass a reference to anything or have a child form or whatever... It's simple. The Settings form deal with only changing the settings, it should do anything else. Let the main form worry about restarting the app, not some child form that shouldn't be worried about such things.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Let me simplify that a little bit... Your Settings form should deal with just that, changing the settings. It shouldn't have anything to do with restarting your application.
Your Main Form should launch the Settings Form as a Dialog (.ShowDialog). When the Settings Form is done saving any changes, it should set a flag exposed as Public in the Settings Form. When closed, control will return back to the Main Form immediately after the .ShowDialog statement. This is where you check that public property on the Settings Form (it's been closed, not removed from memory!) to see if you should restart your application or not. This is where you can launch another copy of your application and quit the current one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How to print the current form or a particular file by browsing the window simply by clicking on the button
|
|
|
|
|
You'r going to have to supply ALOT more detail than this. Printing the current form is no big deal, but what's with the "particular file by browsing the window simply by clicking on the button"? What are you talking about here.
Code: Printing a Windows Form (Visual Basic)[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Also you're going to have to let us know what version of VB you are using, for 6.0 printing the form is really simple (Me.printform), but in VB NET 2003 it's much more complicated. I had to do a project for a class that printed the form in 2003, utter chaos. I'll post the source later.
Treacherous_1
Here's what I came up with, it enables print preview, page setup, and printing in .NET 2003:
_________________________ Printing Form _____________________________
Imports System.Drawing.Printing
Public Class frmMain
Inherits System.Windows.Forms.Form
' storage for form image
Dim formImage As Bitmap
' create API prototype
Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Long
#Region " Windows Form Designer generated code "
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StartPosition = FormStartPosition.WindowsDefaultLocation
End Sub
Private Sub mnuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrint.Click
GetFormImage() 'Takes the screen shot to be printed
If pdbMgrReport.ShowDialog = DialogResult.OK Then
docMgrReport.Print()
End If
End Sub
Private Sub mnuFilePreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePreview.Click
GetFormImage() 'Takes the screen shot to be previewed
Try
ppdMgrReport.ShowDialog()
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Private Sub mnuFileSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSetup.Click
With psdMgrReport
docMgrReport.DefaultPageSettings.Margins.Left = 0.5
docMgrReport.DefaultPageSettings.Margins.Top = 0.5
docMgrReport.DefaultPageSettings.Landscape = True
.PageSettings = docMgrReport.DefaultPageSettings
End With
Try
If psdMgrReport.ShowDialog = DialogResult.OK Then
docMgrReport.DefaultPageSettings = psdMgrReport.PageSettings
End If
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Private Sub mnuFileControl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileControl.Click
nextForm = "frmPreview"
End Sub
Private Sub mnuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileExit.Click
nextForm = "Exit"
Me.Close()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles docMgrReport.PrintPage
e.Graphics.DrawImage(formImage, 50, 50)
End Sub
Private Sub GetFormImage()
Dim g As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
formImage = New Bitmap(s.Width, s.Height, g)
Dim mg As Graphics = Graphics.FromImage(formImage)
Dim dc1 As IntPtr = g.GetHdc
Dim dc2 As IntPtr = mg.GetHdc
' added code to compute and capture the form
' title bar and borders
Dim widthDiff As Integer = _
(Me.Width - Me.ClientRectangle.Width)
Dim heightDiff As Integer = _
(Me.Height - Me.ClientRectangle.Height)
Dim borderSize As Integer = widthDiff \ 2
Dim heightTitleBar As Integer = heightDiff - borderSize
BitBlt(dc2, 0, 0, _
Me.ClientRectangle.Width + widthDiff, _
Me.ClientRectangle.Height + heightDiff, dc1, _
0 - borderSize, 0 - heightTitleBar, 13369376)
g.ReleaseHdc(dc1)
mg.ReleaseHdc(dc2)
End Sub
End Class
_________________________ Print Preview ________________________________
Public Class frmPreview
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub ppcMgrReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ppcMgrReport.Click
Try
ppcMgrReport.Document = docMgrReport
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
End Class
__________________________ Global Variables ____________________________
Module GlobalVariables
Public nextForm As String 'Which form should be displayed next?
Friend WithEvents docMgrReport As System.Drawing.Printing.PrintDocument
Public Sub main()
Dim frmCurrentForm As Form
frmCurrentForm = New frmMain
Do While nextForm <> "Exit"
Select Case nextForm
Case "Preview" : frmCurrentForm = New frmPreview
End Select
frmCurrentForm.ShowDialog()
Loop
End Sub
End Module
|
|
|
|
|
Hi there,
Actually,i'm designing a IQ test program that include a lot of pictures to be display all together at the same time.And it has a option button to select the answer for each question. At the end,I can calculate the result. After i finish the a question, then i can easily go to the next question just by scrolling. So, i need a form big enough to fit all the pictures.
I wonder if VB isn't the right software to use?Or i need to change to other programming language. Thank you, I'm really grateful if you can help me and thanks again.
|
|
|
|
|
VB Means VB6 or VB.Net . if vb.net then enable the scroll bar option in the form property and design your form as big as you want...
|
|
|
|
|
OOO...what is the different between VB6 and VB.NET. Can vb.net complie to an execute file(.exe)?
|
|
|
|
|