
DiverDan
*Experts*
-
Posts
645 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by DiverDan
-
Hi Guys, Using the Printer Class it is not too hard to find all the installed printers and print drivers. But how can I find only the physical printers, like a Lexmark, HP, Epson, etc. Thanks, Dan
-
changing the background color of the selected text in an RTB
DiverDan
replied to njuneardave's topic in Windows Forms
It's been a while since I dug into this so please bear with me. As I remember, you'll need to look into the RTF code and do some string manipulation to set the selected RTF backcolor. Here's the code that I adapted for setting and de-setting a highlight to the selected RTF. Private Sub Add_Highlight(rtf As RichTextBox) If rtf.SelectedText.Length <= 0 Then Exit Sub Try Dim strRTF As String = rtf.SelectedRtf Dim startpos As Integer = strRTF.IndexOf("\uc1") - 1 Dim nextpos As Integer = strRTF.IndexOf("\pard\") + 6 Dim strResult As String If strRTF.IndexOf("highlight1\") < 0 Then strResult = strRTF.Insert(nextpos, "highlight1\").Insert(startpos, HighlightBlackRtf(Color.Yellow)) rtf.SelectedRtf = strResult Else 'if the text is already highlighted strResult = strRTF.Replace("{\colortbl;\red255\green255\blue0;}", "") strResult = strRTF.Replace("highlight1\", "") rtf.SelectedRtf = strResult End If Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub Private Function HighlightBlackRtf(ByVal c As Color) As String Dim strcol As String = "{\colortbl ;\red" & c.R & "\green" & c.G & "\blue" & c.B & ";}" Return strcol End Function I hope this will help you. -
Is gbxSecurityInfo the groupbox that has the controls that you want to loop through? If so then the code is correct. If not then you'll need to change gbxSecurityInfo to the correct groupbox. Another thought is; are you sure that the controls are part of gbxSecurityInfo's controls and not the form's? You might want to check that.
-
Hi SonicBoomAu, The error is correct as the ErrorProvider accesses the control, not its string name. Try this instead: Dim Ctrl As Control Dim txtBox As TextBox Dim combo As ComboBox For Each Ctrl In Me.gbxSecurityInfo.Controls If TypeOf Ctrl Is TextBox Then txtBox = CType(Ctrl, TextBox) If txtBox.Text = String.Empty Then ' Display Error Icon next to control ErrorProvider1.SetError(txtBox, "This field can not be left blank") Else ErrorProvider1.SetError(txtBox, "") End If 'Txt.Text = String.Empty Then End If ' TypeOf CTRL is TextBox If TypeOf Ctrl Is ComboBox Then combo = CType(Ctrl, ComboBox) If combo.Text = String.Empty Then ' Display Error Icon next to control ErrorProvider1.SetError(combo, "This field can not be left blank") Else ErrorProvider1.SetError(combo, "") End If 'Cbo.Text = String.Empty Then End If ' TypeOf Ctrl Is ComboBox Then Next
-
Thanks Marble Eater, With your help I got it working perfectly. Thanks again, Dan
-
Hi, I'm having a problem programmably increasing a panel's AutoScrollPosition. With the lower code, the auto scroll vibrates up and down instead of progressing constantly downward. Private Sub bkrTemp_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bkrTemp.MouseMove Dim pt As Point pt.X = Me.PointToClient(Cursor.Current.Position).X - x pt.Y = Me.PointToClient(Cursor.Current.Position).Y - y With bkrTemp .Location = pt .Capture = True End With If pnlPanel.AutoScroll = True Then Dim bkrLocY As Integer = bkrTemp.Location.Y - (pnlPanel.Location.Y + pnlPanel.AutoScrollPosition.Y) + bkrTemp.Height Dim pnlHeight As Integer = pnlPanel.Height - (pnlPanel.AutoScrollMargin.Height + 17) If bkrLocY + 2 >= pnlHeight Then pnlPanel.AutoScrollPosition = New Point(pnlPanel.AutoScrollPosition.X, pnlPanel.AutoScrollPosition.Y + 5) End If End If End Sub How can I have pnlPanel scroll constantly downward with bkrTemp? Thanks, Dan
-
Marble eater, you'd be better off re-reading the original post a couple of more times than posting ridiculous comments that are just plain wrong...again.
-
This is too simple....Techmanbd's right though, you should show some attempt to solving your problem. But this one is too simple. In your Add button sub: If ckShirt.Checked Then 'add shirt cost ElseIf ckHat.Checked Then 'add hat cost ElseIf ckShoes.Checked Then 'add shoes cost End If
-
From the print page sub: e.Graphics.DrawImage(image, point, etc.) It all depends on where it's to be drawn, where you're getting the image from, the quality of the drawn image, the size of the image, etc.
-
It seems that PlausiblyDamp's link is broken, atleast on this computer anyway. Try: System.Diagnostics.Process.Start("E:\program.exe"). There are a lot of other ways to start your file including parameter settings etc. Check out the Process namespace.
-
How to delete a file in VB.NET
DiverDan
replied to laroberts's topic in Directory / File IO / Registry
Well you're right SimDuck, can't do it with a dll. But I did create an exe that would. From you're current form's button click sub: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If System.IO.File.Exists(Application.StartupPath & "\DeleteExe.exe") Then System.Diagnostics.Process.Start(Application.StartupPath & "\DeleteExe.exe") End If End Sub Then with a new project named DeleteExe, set the form to bordless with a size of 0,0 In its Form Load sub: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim proc As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("WindowsApplication1") If proc.GetUpperBound(0) >= 0 Then proc(0).Close() If System.IO.File.Exists(Application.StartupPath & "\WindowsApplication1.exe") Then System.IO.File.Delete(Application.StartupPath & "\WindowsApplication1.exe") End If End If Me.Close() End Sub I don't know if this will fix your application, but it works. And exchange "WindowsApplication1" with your project's exe name. Also, this example only deletes the calling program. You can obviously change the deleation process to a directory. -
How to delete a file in VB.NET
DiverDan
replied to laroberts's topic in Directory / File IO / Registry
One very simple thought is to have your .exe app call a .dll app on closing. The .dll app would start with a timer then delete the required directory. -
How to delete a file in VB.NET
DiverDan
replied to laroberts's topic in Directory / File IO / Registry
I could be wrong but ("J:\OperationsGenie\JobsHelp\Monday\ThirdShift\{0}.rtf" looks like an .rtf file to me and not an executable. -
How to delete a file in VB.NET
DiverDan
replied to laroberts's topic in Directory / File IO / Registry
You'll need to load the file with a stream reader into a variable. Then close the stream reader to release the file for deletion. -
Another way is to use the .WaitForExit properity with pApp.
-
Thanks for the reply Mark007!!! Although my app is not Excel, your post did give me a lot of ideas that solved the problem. Thanks for your help! Dan
-
Hi, I have a program that saves worksheet type files. How can I detect if a worksheet file is already in use by another user on a network? In other words, if worksheet file A is being used by User A, if User B tries to open worksheet file A I can display a message box that the file is already in use by another User. Thanks, Dan
-
Good call mskeel, I forgot about Skybound as it works effortlessly without any of the visual style bugs, even on my monster program.
-
If you are using 2003 you might consider the manifest file over EnableVisualStyles as there are a few bugs with the EnableVisualStyles depending on your program that will cause your program to crash.
-
If you looking for an XP look with VS2003 then in the main forms New sub located in the "Windows Form Designer generated code" region add the following. Application.EnableVisualStyles Application.DoEvents If you're using VS2002 then you'll need to wirte a manifest file. You'll get lots of examples from a Google search. I haven't used 2005 yet, but I understand that it automatically sets VisualStyles without any of the possible bugs that VS2002 and 2003 shared using the XP look. Also, you'll need to set your controls to System for the XP style.
-
I think I'd look at divil's SandBar: http://www.divil.co.uk/net/ before compromising to a cheesy VS control.
-
Are we talking about the ToolBar Buttons as there is a button style properity. After selecting the tool bar in designer mode, select the Buttons Collection properity. Then find Style under the Misc. section and select ToggleButton. You'll then use the e.Button.Pushed method to find the selected tool bar button.
-
I think Divil's menu control might be what you are looking for. http://www.divil.co.uk/net/
-
Will setting the button style property to ToggleButton be what you're looking for? This will leave the clicked button in a detent position and thus visually differentiate it from the others.
-
Here's a suggestion for establishing an Excel worksheet. Dim excelApp As New Excel.Application If excelApp Is Nothing Then MessageBox.Show("Excel Installation Error", "Microsoft Excel must be installed on this computer for this feature to operate.") End If Cursor.Current = Cursors.AppStarting Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet) Dim row as Integer = 1 With excelWorksheet .Cells(row, 1).Value = "Add Something Here" .Cells(row, 1).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft .Cells(row, 1).Font.Bold = True End With 'OR With excelWorksheet .Cells(row, 1).Value = "Add Something Here" .Cells(row, 1).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft .Range(row & "1:L1").Font.Bold = True 'you can write a function here to convert a numeric column number to a letter End With excelWorksheet.Columns.AutoFit() Cursor.Current = Cursors.Default excelApp.Visible = True I hope this helps.