divil
*Gurus*-
Posts
3026 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by divil
-
What can I say, sometimes you have to leave the comfort of the designers and actually write some code :P :)
-
Ok, after doing a little research on the matter I have a couple of ideas. You should hook up the events in the SetImageIndex function. Every Component has a protected DesignMode property so you can see whether or not to change the properties based on that. As far as making sure you've hooked up events for *every* menu item, I'm a little stumped as to the best way to do this. My best idea as the moment is, whenever a call is made to SetImageIndex, you hook up the Popup event of the parent menu (if you haven't already done so). Now, when that event fires, you loop through all child menus, and if you haven't set their OwnerDraw properties, do so then. I'm sure there must be a better way to do this but haven't found one in the limited time I've been able to devote to this. The MainMenu class offered a promising GetForm() method, which unfortunately returns null at that stage. If it didn't, one could hook the Load event of the Form, to find all menus and ownerdraw them. If you find a better way, be sure to post it!
-
There is no longer a default instance of a form with the same name. Forms are just classes, and you need to declare an instance of them before you can work with them.
-
I don't know exactly what that code is supposed to do, but it isn't very good. To start with, you're hardcoding Windows paths, which is a big no no. Then you seem to be calling some Start function which doesn't actually exist, unless you've imported something I'm not aware of, in which case you need to specify. Bottom line, to anyone reading this, ignore the code posted above and use the Process.Start function.
-
If you're using VB, the redistributable exe will be in the bin folder under your project. If using C#, it'll be in the bin\Debug (or whatever configuration you're using) folder.
-
I went to the help for the PrintDocument class and right there there is an example on how to print a text file from your hard drive. [mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDrawingPrintingPrintDocumentClassTopic.htm[/mshelp] Public Class PrintingExample Inherits System.Windows.Forms.Form Private components As System.ComponentModel.Container Private printButton As System.Windows.Forms.Button Private printFont As Font Private streamToPrint As StreamReader Public Sub New() ' The Windows Forms Designer requires the following call. InitializeComponent() End Sub ' The Click event is raised when the user clicks the Print button. Private Sub printButton_Click(sender As Object, e As EventArgs) Try streamToPrint = New StreamReader("C:\My Documents\MyFile.txt") Try printFont = New Font("Arial", 10) Dim pd As New PrintDocument() AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage pd.Print() Finally streamToPrint.Close() End Try Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub ' The PrintPage event is raised for each page to be printed. Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs) Dim linesPerPage As Single = 0 Dim yPos As Single = 0 Dim count As Integer = 0 Dim leftMargin As Single = ev.MarginBounds.Left Dim topMargin As Single = ev.MarginBounds.Top Dim line As String = Nothing ' Calculate the number of lines per page. linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) ' Print each line of the file. While count < linesPerPage line = streamToPrint.ReadLine() If line Is Nothing Then Exit While End If yPos = topMargin + count * printFont.GetHeight(ev.Graphics) ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat()) count += 1 End While ' If more lines exist, print another page. If Not (line Is Nothing) Then ev.HasMorePages = True Else ev.HasMorePages = False End If End Sub ' The Windows Forms Designer requires the following procedure. Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.printButton = New System.Windows.Forms.Button() Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(504, 381) Me.Text = "Print Example" printButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft printButton.Location = New System.Drawing.Point(32, 110) printButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat printButton.TabIndex = 0 printButton.Text = "Print the file." printButton.Size = New System.Drawing.Size(136, 40) AddHandler printButton.Click, AddressOf printButton_Click Me.Controls.Add(printButton) End Sub ' This is the main entry point for the application. Public Shared Sub Main() Application.Run(New PrintingExample()) End Sub End Class
-
HTML Help Workshop insert a helpfile in a vb.net program
divil replied to Datahighway's topic in General
I haven't actually ever used this, but looking at the help file I think you should be doing: Help.ShowHelp(Me, "myhelp.chm") -
I'd use the DHTML Edit control, if that's what you need. It does everything you want to, and you can take the HTML for the document and stick it in to a database easily. You already have this control, it ships with Internet Explorer. If you have vs.net, the latest version is probably installed here: Program Files\Common Files\Microsoft Shared\Triedit\dhtmled.ocx
-
Sorry, I have no idea what could cause this. Especially not if it works in your browser. .NET certainly shouldn't be doing anything that IE isn't when it downloads data.
-
I don't know why that would download data from the wrong site. I use a different snippet to download stuff from HTTP locations though, perhaps this one would work a little differently: Dim wcDownload As New System.Net.WebClient() Dim bytDatabuffer As Byte() = wcDownload.DownloadData(strURL) Dim strDatabuffer As String = System.Text.Encoding.ASCII.GetString(bytDatabuffer)
-
Sorry, I don't know anything about doing that. Someone else here might though.
-
Try adding text like this: txtDebug.SelectionStart = txtDebug.Text.Length txtDebug.SelectedText = strText & Environment.NewLine And you'll find it scrolls to the bottom automatically as new text is added. The method you are presently using is not very efficient at all, you are resetting the whole text every time you add to it.
-
Can you clarify which type of watermarking you mean? I know of a method of inserting data in to an image file which isn't displayed, which is referred to as watermarking, and I know of the technique of showing a semi-transparent image in a corner of an image, also known as watermarking.
-
How are you adding text to the textbox? I think if you use AppendText, it should scroll with the text as it's added. It does in my experience anyway. As for your other question, it depends on what you're doing really. It does sound as if you might have a good use for threading there. It may be simple enough to stick an Application.DoEvents() in your intensive loop. If you don't find a solution, let us know what your loop is doing and for how long, and we'll be able to advise better.
-
HTML Help Workshop insert a helpfile in a vb.net program
divil replied to Datahighway's topic in General
Once you have your .chm file, you use the Windows Forms HelpProvider class (which should be on your toolbox) to associate things with your help file. [mshelp]ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskIntegratingHelpIntoWFCClientApplicationWithHelpProviderControl.htm[/mshelp] Once you drop this component on your form your controls on the form should gain extra properties, which can be used to link them to the help file. You can also use Windows.Forms.Help.ShowHelp() to display your help file manually. -
Why not read the Microsoft pages about it? http://msdn.microsoft.com/vstudio/productinfo/vstudio03/default.asp Read the information for all the .net languages and the new .net framework too, if you want as much info as possible. It will be a very inexexpensive upgrade ($30 has been mooted) for vs.net owners.
-
No, the compiled code doesn't create overloads. The .NET framework itself DOES support optional parameters, and it gets compiled just fine. It is C# itself that doesn't support optional parameters.
-
Also, check out the AutoScale property of the Form. Supposedly, it should handle at least some of process for you.
-
Next time, please mention that this is an ASP.NET question.
-
If Panel1.Bounds.IntersectsWith(Panel2.Bounds) Then 'Execute sub here
-
Dim frmComp As New frmComp() frmComp.MDIParent = Me.MDIParent frmComp.Show()
-
This seems like a very odd way of doing things... You could only keep two instances around by placing a reference to them in shared fields of the two forms I suppose. Your message loop will have to be such that it doesn't rely on one form, i.e. use Application.Run() from your startup method. If you get really stuck, I'll knock up an example.
-
Well, when you create the node you'd set it's tag property, like so: Dim d As New TreeNode("blah") d.Tag = Panel1 myTreeView.Nodes.Add(d) Then, in the AfterSelect event of the treeview, you'd have to run a loop to hide all visible panel controls on the form, and then show the control associated with the selected node: Dim c As Control For Each c In Controls If typeof c Is Panel Then c.Hide() Next DirectCast(e.Node.Tag, Panel).Show() I made that up on the spot and haven't tested it, but something like that should work.
-
error when opening excel file
divil replied to shankar's topic in Interoperation / Office Integration
Your application is looking for the Interop.Excel.dll files. You should not copy files from the obj\Debug folder. This folder is used by Visual Studio while it's performing background compilation of your solution and isn't meant to be deployed. Instead, look in the Bin folder. In there should be your EXE file and any dll dependancies it may have. It should be sufficient to copy these to the target location. Nothing should need registering, provided your user has Excel installed. If you DO want to make a proper install wizard, Visual Studio .NET comes with a setup project template you can use. It should be there along with the VB.NET and C# projects when you create a new project. If you do that, it will (or should) detect any dependancies and package them in with your app. -
There isn't really a better way. Personally I use panel controls to host all the different child controls, and hide and show the panel controls as needed. If you attach a panel control to the .Tag of a treenode you can pretty much automate the process too.