Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. FlowLayoutPanel1 and controls

FlowLayoutPanel1 and controls

Scheduled Pinned Locked Moved Visual Basic
comquestion
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Ammar_Ahmad

    Hi, Currently when I add a new control to the FlowLayoutPanel1, it gets added to the bottom of all the previous controls that were added in FlowLayoutPanel1. Is there a way that I can add the new controls to the top of FlowLayoutPanel1? I have added a small diagram of what I want: http://foto.pk/images/havewant.png[^] Please note that the flowdirection property isn't giving me the effect that I need. Because new items (controls) are added while the app is running. Source code of the application added: http://www.mediafire.com/?1uo8zd3ybgdmiwp[^] *Note: The above download has all the twitter keys for my account so you don't have to make a new account or anything. Please don't misuse it. Can you please add that feature that I want in the source?

    N Offline
    N Offline
    Nick Otten
    wrote on last edited by
    #2

    Hey, Have you try'd settings the index of the new control?

    FlowLayoutPanel1.Controls.SetChildIndex(Button1, 0)

    Here button1 is my control as control and 0 (int) is the new index of the control in the flowlayoutpanel.

    A 1 Reply Last reply
    0
    • N Nick Otten

      Hey, Have you try'd settings the index of the new control?

      FlowLayoutPanel1.Controls.SetChildIndex(Button1, 0)

      Here button1 is my control as control and 0 (int) is the new index of the control in the flowlayoutpanel.

      A Offline
      A Offline
      Ammar_Ahmad
      wrote on last edited by
      #3

      Not quiet sure how that is done as I am new to controls and flowlayoutpanel. Here is the code that adds the tweets(items) into the control that I have made:

      Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
      If (Me.FlowLayoutPanel1.InvokeRequired) Then
      Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
      Else
      Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))
      Me.FlowLayoutPanel1.Controls.Add(New TweetTimelineControl(tweet))

          End If
      End Sub
      

      Private Sub NewTweet(ByVal tweet As TwitterStatus)
      On Error Resume Next
      AddTestTweet(tweet)
      End Sub

      And here is the control:

      Public Class TweetTimelineControl
      Public Sub New(ByVal status As TwitterStatus)
      Me.InitializeComponent()

          Me.userPictureBox.LoadAsync(status.User.ProfileImageLocation)
          Me.UserNameLabel.Text = status.User.ScreenName
          Me.Label2.Text = status.CreatedDate.ToShortDateString()
          Me.DateLabel.Text = status.CreatedDate.ToShortTimeString()
          Me.TextLabel.Text = status.Text
          Me.Label1.Text = "Number Of Retweets: " & status.RetweetCountString
      End Sub
      

      End Class

      Can you please tell me how to do this on the code given above?

      N 1 Reply Last reply
      0
      • A Ammar_Ahmad

        Not quiet sure how that is done as I am new to controls and flowlayoutpanel. Here is the code that adds the tweets(items) into the control that I have made:

        Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
        If (Me.FlowLayoutPanel1.InvokeRequired) Then
        Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
        Else
        Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))
        Me.FlowLayoutPanel1.Controls.Add(New TweetTimelineControl(tweet))

            End If
        End Sub
        

        Private Sub NewTweet(ByVal tweet As TwitterStatus)
        On Error Resume Next
        AddTestTweet(tweet)
        End Sub

        And here is the control:

        Public Class TweetTimelineControl
        Public Sub New(ByVal status As TwitterStatus)
        Me.InitializeComponent()

            Me.userPictureBox.LoadAsync(status.User.ProfileImageLocation)
            Me.UserNameLabel.Text = status.User.ScreenName
            Me.Label2.Text = status.CreatedDate.ToShortDateString()
            Me.DateLabel.Text = status.CreatedDate.ToShortTimeString()
            Me.TextLabel.Text = status.Text
            Me.Label1.Text = "Number Of Retweets: " & status.RetweetCountString
        End Sub
        

        End Class

        Can you please tell me how to do this on the code given above?

        N Offline
        N Offline
        Nick Otten
        wrote on last edited by
        #4

        Hey I gotte say i dont know your program so this is a bit of guessing. But from what you send i would suggest you place the code into your AddTestTweet sub.

        Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
        If (Me.FlowLayoutPanel1.InvokeRequired) Then
        Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
        Else
        Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))
        Me.FlowLayoutPanel1.Controls.Add(New TweetTimelineControl(tweet))

        ' Me.FlowLayoutPanel1.Controls.SetChildIndex(,)
        End If
        End Sub

        A 1 Reply Last reply
        0
        • N Nick Otten

          Hey I gotte say i dont know your program so this is a bit of guessing. But from what you send i would suggest you place the code into your AddTestTweet sub.

          Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
          If (Me.FlowLayoutPanel1.InvokeRequired) Then
          Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
          Else
          Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))
          Me.FlowLayoutPanel1.Controls.Add(New TweetTimelineControl(tweet))

          ' Me.FlowLayoutPanel1.Controls.SetChildIndex(,)
          End If
          End Sub

          A Offline
          A Offline
          Ammar_Ahmad
          wrote on last edited by
          #5

          Nope. Still don't get it. Here I have uploaded the entire source code: http://www.mediafire.com/?1uo8zd3ybgdmiwp[^] *Note: The above download has all the twitter keys for my account so you don't have to make a new account or anything. Please don't misuse it. Can you please add that feature that I want in the source?

          N 1 Reply Last reply
          0
          • A Ammar_Ahmad

            Nope. Still don't get it. Here I have uploaded the entire source code: http://www.mediafire.com/?1uo8zd3ybgdmiwp[^] *Note: The above download has all the twitter keys for my account so you don't have to make a new account or anything. Please don't misuse it. Can you please add that feature that I want in the source?

            N Offline
            N Offline
            Nick Otten
            wrote on last edited by
            #6

            I got the file, so you can remove the link if you want. Cant promise i can get to it ASAP, but i will see if i can paste in the code you need. EDIT: Oke got a quick look at it during work. the twitter is blocked here so i cant actually test it. but i think if you replace your AddTestTweet sub with this one it will work.

            Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
            If (Me.FlowLayoutPanel1.InvokeRequired) Then
            Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
            Else
            Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))

                    Dim storedtweet As New TweetTimelineControl(tweet)
                    Me.FlowLayoutPanel1.Controls.Add(storedtweet) 
                    Me.FlowLayoutPanel1.Controls.SetChildIndex(storedtweet, 0)
            
                End If
            End Sub
            

            Like i said its untested so don't shoot me if it adds to the bottom, try playing with the 0 if this happends(make it FlowLayoutPanel1.Controls.Count for example).

            A 1 Reply Last reply
            0
            • N Nick Otten

              I got the file, so you can remove the link if you want. Cant promise i can get to it ASAP, but i will see if i can paste in the code you need. EDIT: Oke got a quick look at it during work. the twitter is blocked here so i cant actually test it. but i think if you replace your AddTestTweet sub with this one it will work.

              Private Sub AddTestTweet(ByVal tweet As TwitterStatus)
              If (Me.FlowLayoutPanel1.InvokeRequired) Then
              Me.FlowLayoutPanel1.Invoke(New AddTestTweetDelegate(AddressOf AddTestTweet), tweet)
              Else
              Console.WriteLine(String.Format("New tweet: @{0}: {1}", tweet.User.ScreenName, tweet.Text))

                      Dim storedtweet As New TweetTimelineControl(tweet)
                      Me.FlowLayoutPanel1.Controls.Add(storedtweet) 
                      Me.FlowLayoutPanel1.Controls.SetChildIndex(storedtweet, 0)
              
                  End If
              End Sub
              

              Like i said its untested so don't shoot me if it adds to the bottom, try playing with the 0 if this happends(make it FlowLayoutPanel1.Controls.Count for example).

              A Offline
              A Offline
              Ammar_Ahmad
              wrote on last edited by
              #7

              Alright. Thanks.

              N 1 Reply Last reply
              0
              • A Ammar_Ahmad

                Alright. Thanks.

                N Offline
                N Offline
                Nick Otten
                wrote on last edited by
                #8

                Edited my last message with a possible solution.

                A 1 Reply Last reply
                0
                • N Nick Otten

                  Edited my last message with a possible solution.

                  A Offline
                  A Offline
                  Ammar_Ahmad
                  wrote on last edited by
                  #9

                  That worked beautifully! :D Thanks m8!

                  N 1 Reply Last reply
                  0
                  • A Ammar_Ahmad

                    That worked beautifully! :D Thanks m8!

                    N Offline
                    N Offline
                    Nick Otten
                    wrote on last edited by
                    #10

                    no problem! glad to be of help (tough as it seems a formality here: remember to vote :cool:)

                    A 1 Reply Last reply
                    0
                    • N Nick Otten

                      no problem! glad to be of help (tough as it seems a formality here: remember to vote :cool:)

                      A Offline
                      A Offline
                      Ammar_Ahmad
                      wrote on last edited by
                      #11

                      Already done :D

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups