Jump to content
Xtreme .Net Talk

Machaira

Avatar/Signature
  • Posts

    330
  • Joined

  • Last visited

Everything posted by Machaira

  1. I can't get this problem to occur. Can you post the project in which this occurs?
  2. I agree, but this isn't necessarily the case here. So in the end what's the difference between using a module and what you've done? What's the benefit for doing it your way? Using a module still provides for a modular solution without all the fuss of using a class. "proper .NET code"? So using modules isn't "proper .NET"? MS must think there's a reason for them. They're still a part of VB.NET 2005. Using a module doesn't increase the difficulty of debugging, doesn't slow it down, doesn't break OOP methodology, and, above all, doesn't make it more complex than it needs to be.
  3. In your declaration of the variable change Dim to Public and you should be good. By default Dim means the scope is local, which in this case is the module, not any forms in the project.
  4. Sure you can: Me.Location = New Point(10000, 0)
  5. Save the filename in the PictureBox's Tag property when you load it. When you want to save it just grab the filename from the Tag property.
  6. You can make the child a member of the parent. Move the declaration for NewMDIChild to the Declarations section of the form, set the MdiParent property in Form1's constructor or Load event and just show the child when the button is clicked instead of creating a new instance every time.
  7. You could always include a function in the DLL to return this information if there's no way to get it from the outside.
  8. NP. Free free to post any follow-up if you have problems with it. I whipped it up in a few minutes so there might be some gotchas that develop. :)
  9. Without seeing what you're doing I doubt we can help much.
  10. Doesn't look like it. Just rename the original to a temp name, create the new one and move the files and folders in the original.
  11. Are you looking for the SelectedItem property of the ComboBox?
  12. Off the top of my head: Each object could contain a Parent property that gets assigned when you create the object. Raise the Change event to the parent. Am I missing something? Here's some quick code: Public Class BaseObject Private _parent As BaseObject Private _name As String Private _children As New Collection Public Property Parent() As BaseObject Get Return _parent End Get Set(ByVal Value As BaseObject) If _parent Is Nothing Then _parent = New BaseObject _parent = Value End Set End Property Public Property Name() As String Get Return _name End Get Set(ByVal Value As String) _name = Value End Set End Property Public Property Children() Get Return _children End Get Set(ByVal Value) End Set End Property Public Sub AddChild(ByVal child As Object) child.Parent = Me _children.Add(child) End Sub Public Sub Change() Debug.WriteLine("Change handled by BaseObject: " & Name) End Sub End Class Public Class EventObject Inherits BaseObject Public Shadows Sub Change() Debug.WriteLine("Change event handled by EventObject: " & Name) Me.Parent.Change() End Sub End Class Public Class ActionObject Inherits BaseObject Public Shadows Sub Change() Debug.WriteLine("Change event handled by ActionObject: " & Name) Me.Parent.Change() End Sub End Class Public Class CasualtyObject Private _parent As ActionObject Private _name As String Public Sub New() _parent = New ActionObject End Sub Public Property Parent() As ActionObject Get Return _parent End Get Set(ByVal Value As ActionObject) _parent = Value End Set End Property Public Property Name() As String Get Return _name End Get Set(ByVal Value As String) _name = Value End Set End Property Public Sub Change() Me.Parent.Change() End Sub End Class 'test bed Dim obj As New EventObject Dim child As Object Dim child2 As Object obj.Name = "Parent" child = New EventObject CType(child, EventObject).Name = "Child 1" obj.AddChild(child) child = New ActionObject CType(child, ActionObject).Name = "Child 2" child2 = New CasualtyObject CType(child2, CasualtyObject).Name = "Child 3" child.AddChild(child2) obj.AddChild(child) CType(child2, CasualtyObject).Change()
  13. I changed it a bit and it works fine for me: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim num As Integer = 5 Dim CheckBoxx(num) As CheckBox Dim Panel1 As New Panel Panel1.Location = New Point(10, 30) Panel1.Size = New Size(400, 350) Panel1.BorderStyle = BorderStyle.Fixed3D Me.Controls.Add(Panel1) For intCounter As Integer = 0 To num CheckBoxx(intCounter) = New CheckBox CheckBoxx(intCounter).Size = New Size(15, 15) CheckBoxx(intCounter).Location = New Point(20, intCounter * 25) Panel1.Controls.Add(CheckBoxx(intCounter)) AddHandler CheckBoxx(intCounter).CheckedChanged, AddressOf CheckChanged Next End Sub Private Sub CheckChanged(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show("Check changed") End Sub
  14. Here's my take: Example 1: Dim str as String = "" Dim i as integer i = Len(str) i = str.Length Example 2: Dim str as String Dim st2 as String Dim len As Integer str = "ABC" str2 = Microsoft.VisualBasic.Left(str, 5) len = str.Length() If len > 5 Then len = 5 str2 = str.Substring(0, len) Your examples are very bad examples. In real applications you cannot make assumptions like you have here. If you're doing that you should change your practices. Just because VB 6 let you get away with things like this doesn't mean you should do them.
  15. Why not just use one of the classes derived from the Array class?
  16. If I'm understanding you correctly you won't be able to do the first thing. Only one control can have focus at one time so you can't type in a textbox and use the arrow keys to move around in the list unless you handle the arrow keys in one of the textbox's Key events. As for the second part you can do something like: ListBox1.SelectedIndex = ListBox1.FindString(TextBox1.Text)
  17. How about instead of maximizing the form, just resize it to fit the client area of the MDI form?
  18. :eek: :eek: :eek: ;) :cool:
  19. Unless I'm missing something, you just set the Name property like you would any other.
  20. You have to consider the fact that MFC is ancient in industry time. I never did like MFC. It seemed more convoluted and difficult than necessary. What I don't understand is why a book on .NET programming would be having you make MFC apps? That's just silly. Try creating a Windows Form Application project in C++ instead.
  21. When you get the data from the table, ensure that you sort by parent, child, filename. Try the following: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable Dim iLp As Integer Dim parent As TreeNode Dim child As TreeNode Dim filename As TreeNode 'da is a DataAdapter for the table da.Fill(dt) For iLp = 0 To dt.Rows.Count - 1 parent = FindParent(dt.Rows(iLp).Item(0)) If parent Is Nothing Then parent = TreeView1.Nodes.Add(dt.Rows(iLp).Item(0)) End If child = FindChild(parent, dt.Rows(iLp).Item(1)) If child Is Nothing Then child = parent.Nodes.Add(dt.Rows(iLp).Item(1)) End If filename = FindChild(child, dt.Rows(iLp).Item(2)) If filename Is Nothing Then filename = child.Nodes.Add(dt.Rows(iLp).Item(2)) End If Next iLp End Sub Private Function FindParent(ByVal treeText As String) As TreeNode Dim node As TreeNode For Each node In TreeView1.Nodes If node.Text = treeText Then Return node Next node Return Nothing End Function Private Function FindChild(ByRef node As TreeNode, ByVal treeText As String) As TreeNode Dim child As TreeNode For Each child In node.Nodes If child.Text = treeText Then Return child Next child Return Nothing End Function
  22. Without seeing what you've done it's hard to help.
  23. Here's a beta version of what I whipped up. It could use some tweaking, but it's workable I think.DateNotes.zip
  24. Looks like you have something in the control that isn't being created. What the code in the control's constructor or Load event look like?
  25. I believe you mean Quake2.NET :)
×
×
  • Create New...