Results 1 to 6 of 6

Thread: [RESOLVED] Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Resolved [RESOLVED] Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    Hi,

    I've used this arrangement in other projects and not had this problem.

    I have a TableLayoutPanel within a Panel, the TableLayoutPanel has multiple rows containing ComboBoxes, TextBoxes and DateTimePickers.

    If the TableLayoutPanel is Anchored Top/Left I have no issues, when I set the TableLayoutPanel Anchor to Top/Left/Right or Dock = Fill when I run my application each ComboBoxes value is highlighted.

    I've ensured the containing panel isn't being selected (but why would it only happen when docked?)

    I've tried setting the ComboBox.SelectionLength = 0, and .SelectionStart = Text.Length didn't work but would like a better solution anyway.

    If anyone has any suggestions it would be greatly appreciated, thank you.

    Thank you.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    To deselect any items in your ComboBox... - ComboBox.SelectedIndex = -1

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    Please provide a specific set of steps that we can follow to reproduce the issue.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Re: Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    Paul, thanks for the response. I need an item in the drop down selected, just not highlighted/focused. I'll explain further now and hopefully give you what you need also jmc.

    I have a form with a TableLayoutPanel filling it, 3 main columns, in the right hand column, I have another TableLayoutPanel with multiple rows, in the bottom row I have a CustomPanel (see below) and within that Panel I have the TableLayoutPanel in question.

    CustomPanel:
    vb Code:
    1. Public Class CustomPanel
    2.     Inherits System.Windows.Forms.Panel
    3.  
    4.     Protected Overrides Function ScrollToControl(ByVal activeControl As System.Windows.Forms.Control) As System.Drawing.Point
    5.         Return Me.AutoScrollPosition
    6.     End Function
    7. End Class

    I have a DataGridView in the middle column on my first TableLayoutPanel, A button can be clicked to make the right hand column appear (setting width to 350 instead of 0), in this column within the final TableLayoutPanel I have my controls that display the data from the selected row in the D

    Please see the collection of screenshots showing the layout and the issue.

    Name:  Pane1.PNG
Views: 230
Size:  15.4 KB

    Name:  Pane2.PNG
Views: 262
Size:  15.4 KB

    Name:  Pane3.PNG
Views: 261
Size:  16.5 KB

    Name:  Pane4.PNG
Views: 261
Size:  14.3 KB

    Thank you.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Re: Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    Hi there,

    I've just come back to this now and have found that if the form is big enough so that the autoscroll bar hasn't kicked in, as soon as I resize the form to the point that the auto scroll bar appears, at this point the ComboBoxes suddenly highlight.

    As before if I change (for testing) one of the ComboBoxes Dock from Fill to None, that ComboBox doesn't get highlighted.

    Not sure if that sparks any ideas, but I thought I'd post.

    Thank you.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Re: Strange One - Comboboxes highlight when TableLayoutPanel is Dock = Fill

    Ok,

    So this led me to search differently for the problem, the problem being ComboBox resize.

    The following solved my issue:

    vb Code:
    1. Private Sub MyControl_Resize(sender As Object, e As EventArgs) Handles Me.Resize
    2.  
    3.     MyComboBox.SelectionLength = 0
    4.  
    5. End Sub

    Taken from the following sites:

    https://stackoverflow.com/questions/...-automatically

    https://social.msdn.microsoft.com/Fo...orum=vbgeneral

    Thank you to everyone who took time to read and/or look into this one.

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