Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. Well... In your code you put the filename first then the /Q option, and in the example you provided all of the options came first.
  2. There we go. Thanks. It seems kinda obvious but I actually tried it. The code editor marked the line as having an error, and I assumed it was because I implemented a function privately when it was actually something else.
  3. Nice... only one problem though... I'm using VB.
  4. The IList interface provides the property Item(Index As Integer) As Object, which is read/write. Many classes that implement IList, however, have an Item property which is of a different type and read-only (System.Windows.Forms.Control.ControlCollection and System.Windows.Forms.ListView.ListViewItemCollection for example). If you cast one of these collections to IList, then you can access the property Item(Index As Integer) As Object, but otherwise this property does not show up in intellisense or the object browser. I am making my own collection, which implements IList. How can I reproduce this? [Edit]Also note that this also applies to other members of IList, such as Add, and Insert, not just Item.[/Edit]
  5. Instantiate the System.Random class using the default constructor (no parameters). It will use the system's time as the seed.
  6. Alternatively, if you want to use notepad instead of the default text editor (which is usually notepad) you could do it this way: System.Diagnostics.Process.Start("Notepad.Exe", Document)
  7. Here. Modify this code as necessary and add it to your edit contact form. When you instantiate the form, rather than using the standared constructor [New frmEditContact], pass in the selected ListViewItem [New frmEditContact(lstContacts.SelectedItems(0))]. 'Assuming that your list view items have the following information: Name, Address, Phone Number Dim _Contact As ListViewItem Public Sub New(ByVal ContactInfo As ListViewItem) MyClass.New() 'Initialize ' _Contact = ContactInfo 'Retain a reference to the listview item 'Get the info from the listviewitem and copy it to the textboxes txtName.Text = ContactInfo.SubItems(0).Text txtAdress.Text = ContactInfo.SubItems(1).Text txtPhoneNumber.Text = ContactInfo.SubItems(2).Text 'This should be validatad ' 'This form should be shown using ShowDialog End Sub ' Private Sub btnOK_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles btnOK.Click 'Store the info back into the listview item _Contact.SubItems(0).Text = txtName.Text _Contact.SubItems(1).Text = txtAdress.Text _Contact.SubItems(2).Text = txtPhoneNumber.Text 'Close the form Me.Close() End Sub The form will be displayed with all the contact info, and when the user clicks the okay button (in the code above I named it btnOK) the info will be stored back to the ListViewItem.
  8. Whoops. Certianly a fair question. A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values. I have noticed this behavior before, with the pausing and exceptions and whatnot. Since both the throwing and handling of the exception is happening in the System.Windows.Forms.dll I can't get the details. For the same reason, I have ignored the error in the past, but the pausing is getting on my nerves and I would really like the debugger to break on all exceptions, but when I add 20 items to the listview it is very annoying to break into the debugger 20 times.
  9. This is one way to do it: Add a new constructor (Sub New) to your second form, which accepts a listview item. In the constructor call MyClass.New() to perform the normal initialization. Then set each textbox's .Text property to the appropriate subitem (ListViewItem.SubItems(index).Text [i think]). When the user clicks okay, set all the subitems to the modified textbox's text, and your changes should be reflected in the original listview.
  10. I am making an app that uses a listview. I add ListViewItems to the ListView.Items collection using ListView.Items.Add. Every time I add an item, an exception is thrown and handled within System.Windows.Forms.dll. This is not breaking my application, however it causes a pause when the first exception is thrown. Is this normal behavior? Or some sort of bug? I am not changing any properties after I instantiate the listview items, so I'm nearly positive that I'm not doing anything wrong. I'm sure that Microsoft does not condone using exceptions as a form of program flow control, however this happens every time I add an item not only causing the pause, but making it nearly impossible to debug when the debugger is set to break on all exceptions.
  11. First of all, if you want to do this you need to set the program up for it. The code posted did not set the .Name property of the controls. I don't know if the default name is an empty string or "ComboBox(insert number here)", but even in the case of the latter, there is no guaruntee that the numbers will begin at one (for example, if there is already a combo box named "ComboBox1"). You will need to set the names explicitly. Alternatively, if you object to my method, I would recommend using something like "If sender Is cboLoad(i) Then..." (this requires that you keep a reference to each combobox). Secondly, the "stub" for a combo box SelectedIndexChanged event would be: Sub Pick_A_Name(ByVal sender As System.Object, ByVal e As System.EventArgs) 'You code goes here. 'This is also where you determine which combobox is clicked (if you need to) End Sub To get the signature (stub, delegate, whatever) for any specific event, you can search for the control's class in the object browser, look for the event you want to handle, select it, and look at the definition in the bottom of the window. Alternatively, you can add a control to your form, go to the code editor, select the control in the list of objects in the left combo box at the top of the code window, select the event you want to handle in the right combo box, and VB will insert the handler for you, which you can copy and paste (changing the name and removing the "Handles" clause). Here is an example that will do what you want: Dim cboLoad(26) As ComboBox Sub MakeMeComboBoxesPlease() For x As Integer = 1 To intChannels cboLoad(x) = New ComboBox With cboLoad(x) .Size = New Size(32, 16) .Visible = True .DropDownStyle = ComboBoxStyle.DropDownList .Location = New Point(8, intXPoint) For y As Integer = 0 To 6 Step 2 .Items.Add(y) Next .Tag = x.ToString 'Do this if you want to store the index as a tag .Name = "cboLoad" & x.ToString 'Do this if you want to do a select case using the names AddHandler cboLoad(x).SelectedIndexChanged, AddressOf Pick_A_Name End With Next End Sub Sub Pick_A_Name(ByVal sender As System.Object, ByVal e As System.EventArgs) 'You code goes here. 'This is also where you determine which combobox is clicked (if you need to ) End Sub
  12. If you are using a Deployment Project, just click View>Editor>Registry and add your keys there.
  13. If you want to check every checkbox contained directly by the form (i.e. not in a panel/group box/etc.) you could do this: For Each Item As Control In Me.Controls If Typeof Item Is CheckBox Then DirectCast(Item, CheckBox).Checked=False End If Next Item Likewise, you could do this to a panel's control collection, or any other container control.
  14. What specifically is the problem? Or are you looking for a quick how-to? If the latter is the case, On the MouseDown (or MouseUp, I don't know which would be better) event, check which button was clicked (e.Button). If it was the right button, and there is an item selected (ListView.SelectedItems.Count = 1), pop your context menu up, and if they click "Edit Contact" populate your contact form with the subitems of your listview, show it, when they click OK, modify the selected item using the contents of the contact form.
  15. In other words Dim Names() As String = FullName.Split(" "c) Dim FormattedName As String = Names(0).Substring(0, 1).ToLower() & Names(1).ToLower() You should probably check that Names.Length = 2 (or if it equals three, assume that Names(1) is the middle name and use Names(2) as the last name)
  16. Start by creating a bitmap. You can use the Graphics.FromImage() method to create a graphics object with which to edit your bitmap. Then use the DrawImage() method to merge the two images into one. If you have a color (other than one that is already transparent) which you want to represent transparency, the Bitmap class has a method, MakeTransparent(), which will make any one color become transparent. Alternatively, you could create a graphics object for one of your existing images and simply draw the second image onto the first, resulting in less code and work, but you would lose the original image. 'This code assumes that both images are the same size 'Create new bitmap Dim MergedImage As New Bitmap(Layer1.Width, Layer1.Height, Imaging.PixelFormat.Format32bppArgb) 'And graphics object to edit the image Dim gMergedImage As Graphics = Graphics.FromImage(MergedImage) ' 'Draw the first image gMergedImage.DrawImage(Layer1, 0, 0) 'Magenta will be treated as transparent Layer2.MakeTransparent(Color.Magenta) ' ''Draw the second image normally 'gMergedImage.DrawImage(Layer2, 0, 0) ' 'Draw the second image zoomed in 'You can specify any size rectangle in any location to get zoom and offset Dim DestRect As New Rectangle(-Layer2.Width \ 4, Layer2.Height \ 4, Layer2.Width * 2, Layer2.Height * 2) gMergedImage.DrawImage(Layer2, DestRect) ' 'If you want to show it to the user in a picturebox... Picturebox1.Image = MergedImage Picturebox1.Invalidate() If you want your user to be able to move and resize the image with a preview, keep a reference to the bitmap and graphics objects. You can use the Graphics.Clear() method to clear the image and re-draw the composite image each time the user makes a change to the location or zoom (calling the PictureBox.Invalidate method to refresh the picturebox if you are using one).
  17. I recommend reading the faqs
  18. Would it be possible to use the System.IO.FileSystemWatcher class?
  19. If you are referring to the .NET framework, the user will need the .NET framework installed. There is a redistributable that you can get from Microsoft here, but you may already have it (I don't know if it is included in the SDK): http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&DisplayLang=en If you have a deployment project, you can have this included. Go to Detected Dependencies in the solution explorer, select dotnetfxredist_x86.msm, and go to the property grid. Set exclude to False. It should then be included with the setup program. I don't have a machine that I can test this on right now, so no guarantees. If you create a deployment project, you can use the same method to include any other dlls required. You should also, however, be able to include any of your own, non-.NetFramework, dlls in the application folder, just like VB6.
  20. Sorry, I should have mentioned that the site gives VB6 declarations, not .Net.
  21. Don't overload "ShowDialog". Either shadow it, or just use a different function name.
  22. There are Windows APIs to change the system colors what will automatically refresh everything to ensure that colors are drawn correctly. Have some links. GetSysColor: http://www.mentalis.org/apilist/GetSysColor.shtml SetSysColors: http://www.mentalis.org/apilist/SetSysColors.shtml
  23. If you mean another window contained within the main window, this is possible, but in the example I found on the internet the child window's title bar was always displayed as inactive. Why do you want a child window in a non MDI window?
  24. I don't know if you want a tooltip on menu items. Seems like too many things popping up. Describing what menu items do is generally done via the status bar. On the MenuItem.Select event you can put a tip in the status bar.
×
×
  • Create New...