Jump to content
Xtreme .Net Talk

divil

*Gurus*
  • Posts

    3026
  • Joined

  • Last visited

Everything posted by divil

  1. Controls.IndexOf(myControl) will give the index of any control in the collection. What exactly is the problem with this? And also, you said you didn't want to bother with a hash table, but from what I can see it would simplify your situation. You could add all your controls to it like this: Hashtable h = new Hashtable(); foreach (Control c in Controls) { h.Add(c.Name, c); } // You can now access your controls directly by name: ((Control) h["mycontrol1"]).Text = "blah"; Dim h As New Hashtable() Dim c As Control For Each c In Controls h.Add(c.Name, c) Next 'You can now access your controls directly by name: DirectCast(h("mycontrol1"), Control).Text = "blah"
  2. MS have fixed this lack of a directory picker control in Visual Studio .NET 2003.
  3. It sounds like a verb could do that quite nicely, I've seen them used before to pop up configuration boxes. You could also override DoDefaultAction, so when the user double-clicks the control the dialog is popped up.
  4. When you consider that you can't change anything about a class before the constructor is run (think about it for a second, constructor always comes first) it makes sense.
  5. Hey! Don't I get a say in how I'm divided? :P Anyway - I wouldn't rely on the Paint event for what you need to do. What would probably best is making a designer for your class (see my article, Introduction to Designers) and in the overridden Initialize method of that class, you can call back to the main control to tell it to initialize design-time objects.
  6. Passing the instance to the new form's constructor using the Me (or this) keyword is usually me preferred way of keeping the instances around.
  7. You can do this by subtracting the date returned by the control from the date now: Dim ts As TimeSpan = DateTime.op_Subtraction(DateTime.Now, DateTimePicker1.Value) TimeSpan ts = DateTime.Now - DateTimePicker1.Value;
  8. I can't for the life of me imagine any situation where one would need to differentiate between the two. The whole point is that they behave exactly the same whether you create them in code or the designer creates the code to create them in code :P
  9. bpayne111 is correct, that property does not work in the constructor. I explained why in his post in the General forum.
  10. Did you read what we both said? You could cycle through them once and add them to a hashtable to associate names with controls, if you really must access them this way. [edit]Bah, and again![/edit]
  11. The DesignMode property on a component echoes the DesignMode property of the ISite associated with a component. A component only gets an ISite once it has been sited on a surface, which obviously cannot be done until it's been instantiated - i.e. after the constructor has run. If the component does not yet have an ISite associated with it, the DesignMode property simply returns false. If you are wanting to intitialize object only at design time, I'd suggest you do so in a designer for the control. It's best to keep things separate like this, that way your control has as little design time code running at runtime as possible.
  12. You'll have to create a name-value collection yourself and add the controls at runtime at the start of your application. I don't see why you have to do this, but that's probably what you want to do. The alternative is to actually create the controls at runtime too, but then you have to deal with positioning them manually. [edit]Damn, I was beaten to it[/edit]
  13. That code should work just fine. Are you sure that bitmap exists and is in the correct format?
  14. What about declaring the event as protected? That way it is not public, but is still available to derived classes.
  15. Here's a C# sample that does it (right near the bottom of the page): http://www20.tok2.com/home/tomoaki/CSSAMPLE/CSSAMPLE01.html
  16. Here it is in VB6, perhaps it'll get you started. Public Type SHELLEXECUTEINFO cbSize As Long fMask As Long hWnd As Long lpVerb As String lpFile As String lpParameters As String lpDirectory As String nShow As Long hInstApp As Long lpIDList As Long 'Optional parameter lpClass As String 'Optional parameter hkeyClass As Long 'Optional parameter dwHotKey As Long 'Optional parameter hIcon As Long 'Optional parameter hProcess As Long 'Optional parameter End Type Public Const SEE_MASK_INVOKEIDLIST = &HC Public Const SEE_MASK_NOCLOSEPROCESS = &H40 Public Const SEE_MASK_FLAG_NO_UI = &H400 Public Declare Function ShellExecuteEx Lib "shell32.dll" (SEI As SHELLEXECUTEINFO) As Long Public Sub ShowFileProperties(strFilename As String) 'open a file properties property page for 'specified file if return value Dim SEI As SHELLEXECUTEINFO 'Fill in the SHELLEXECUTEINFO structure With SEI .cbSize = Len(SEI) .fMask = SEE_MASK_NOCLOSEPROCESS Or _ SEE_MASK_INVOKEIDLIST Or _ SEE_MASK_FLAG_NO_UI .hWnd = 0 .lpVerb = "properties" .lpFile = strFilename .lpParameters = vbNullChar .lpDirectory = vbNullChar .nShow = 0 .hInstApp = 0 .lpIDList = 0 End With 'call the API to display the property sheet Call ShellExecuteEx(SEI) End Sub
  17. As far as I know there isn't a .NET way to do this. I've done it in vb6 before using ShellExecuteEx, you will probably be able to find an example online but you'll have to port it to .NET.
  18. See the Microsoft.Win32.Registry class, and start from there. The GetValue method of the RegistryKey class seems to support getting binary data from a key, I would guess it would return a byte array.
  19. You may have to implement ISerializable to explicitly control which members are serialized, by default everything is. And, like you said, NonSerializedAttribute can only be applied to fields.
  20. It sounds like you want to search for a repository of algorithms, there are a few out there.
  21. The Mono project has come a long way. I am told it is even compiling and running simple windows forms applications now.
  22. Good question - you may have to do things manually, but on the other hand you might get away with just adding the controls to the usercontrol at design time using IDesignerHost.CreateComponent to create them. That way they'll have the designers created for them that they would if they were hosted on a normal design surface.
  23. And the DesignMode property is likely what you're looking for, although it won't work in the constructor.
  24. You find one that plays wav files.
  25. divil

    icon from exe

    Check out VolteFace's sample code here. It should do what you need, get the displayed icon from any file path.
×
×
  • Create New...