Results 1 to 7 of 7

Thread: [RESOLVED] Custom control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    265

    Resolved [RESOLVED] Custom control

    Hi All,
    i need some suggestions on how to achieve this please, my program records team and team member names as they come in. i need to display these teams (in this order: Last in shows first ) in blocks, with name, members and a close button, see attached image, i was thinking a custom control with a label header, gridview and a button. and create these objects on the fly, as more teams come in, and maybe use a table layout control.
    Any better suggestions are appreciated'
    Thanks in advance


    Name:  vbforums.png
Views: 237
Size:  19.6 KB

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Custom control

    Well, yes, to all of those things except the gridview. That's overkill for a simple list. I'm not sure I really understand the last in shows first thing and you're gonna have problems doing that with a table layout panel (or any other control for that matter) as it stands. You'd need to clear the panel and add all the controls running backward through a list on each occasion. Perhaps you could also come up with a Stack Table Layout Custom Control while you're at it?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    265

    Re: Custom control

    Last in must show on top left, i may drop the table layout and just work with location properties. you are right I guess, this requires repositioning the objects for every new team or when a team is closed

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Custom control

    I think a single column DataGridView on a UserControl can do just fine for this. You can put the close button underneath the grid on the UserControl.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Custom control

    Here's a reverse order flow panel for you. It only works with dynamically added controls but that's what you want.

    vb.net Code:
    1. Public Class ReverseFlowLayoutPanel
    2.     Inherits Panel
    3.     Private CList As New List(Of Control)
    4.     Private CLocation As Point
    5.  
    6.     Sub New()
    7.         CLocation = New Point(5, 5)
    8.     End Sub
    9.  
    10.     Protected Overrides Sub OnControlAdded(e As System.Windows.Forms.ControlEventArgs)
    11.         CList.Add(e.Control)
    12.         SetLocation()
    13.         MyBase.OnControlAdded(e)
    14.     End Sub
    15.  
    16.     Protected Overrides Sub OnControlRemoved(e As System.Windows.Forms.ControlEventArgs)
    17.         CList.Remove(e.Control)
    18.         SetLocation()
    19.         MyBase.OnControlRemoved(e)
    20.     End Sub
    21.  
    22.     Private Sub SetLocation()
    23.         For i = CList.Count - 1 To 0 Step -1
    24.             If Not Me.AutoSize AndAlso CLocation.X + CList(i).Width + 5 > Me.Width Then
    25.                 CLocation.X = 5
    26.                 CLocation.Y = CLocation.Y + CList(i).Height + 5
    27.             End If
    28.             CList(i).Location = CLocation
    29.             CLocation.X = CLocation.X + CList(i).Width + 5
    30.         Next
    31.         CLocation = New Point(5, 5)
    32.     End Sub
    33. End Class
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    265

    Re: Custom control

    Thanks Guys, much appreciated. Devexpress xtraGrid Card view does exactly what i want in just one line of code

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    265

    Re: [RESOLVED] Custom control

    I ended up going with dumfiddlin suggestion, just encountring a tiny issue but i'v been pulling my hair to resolve it. after adding the custom controls into the form, see structure below,

    -- Main Form
    -- > Screen Form : called from Main Form on a button click (ShowDialog(me))
    -- > User controls: dynamically added to Screen Form

    It is all fine except, on each added User control, first cell on first row of the dataGrid seems to inherit the background of MainForm e.g. cell(0,0) backround would be the object with similar location property on MainForm, which in my case is a button, so my cell bakgnd is the button colour and a part of the button text property.
    I tried me.refresh on the userControl constructer, but was no joy , any ideas ???? Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width