VS 2017 Get rid of Highlights-VBForums
Results 1 to 29 of 29

Thread: Get rid of Highlights

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Get rid of Highlights

    This is not a hair thing.

    Here is an example of a form that is highlighting controls.

    Name:  change Request.jpg
Views: 119
Size:  42.6 KB

    This is the form as it is displayed after the load event is executed. I would really prefer to not have any of these controls highlighted. I have looked for a properties setting for that and have been unable to find one.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,104

    Re: Get rid of Highlights

    Well, unless they are custom controls, they don't magically highlight their text unless there's code added to highlight the text. So, no, you're not going to find a property for it. At least not directly. There's probably code somewhere that sets the SelectionStart and SelectionLength (or SelStart, SelLength)... so look for that.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Well Tech, I can assure you that there is nowhere in the code (or otherwise) that I asked those controls to be highlighted. I searched through the code and the nearest thing I found to that was where I set all three of the comboboxes to SelectedIndex = -1. I also set tabstops and TabIndex on some of the controls.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,578

    Re: Get rid of Highlights

    It's also worth noting that the HideSelection property controls whether selected text is highlighted when a TextBox doesn't have focus. That said, I think that the highlight is blue when focused and grey when not. I haven't tested to confirm that though.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    It would appear then that the focus should be set to off/false for those controls. How does one do that?

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,578

    Re: Get rid of Highlights

    Quote Originally Posted by gwboolean View Post
    It would appear then that the focus should be set to off/false for those controls. How does one do that?
    No it would not. Only one control can have focus at a time, so the issue can't possibly be that multiple controls have focus.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    That is a very good thing to know JM. Perhaps you might be willing to enlighten me as to what might be causing this phenomenon and how to remediate the cause?

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,578

    Re: Get rid of Highlights

    I've already given you all the information you need on the only cause I can think of based on standard functionality. If it's some custom control that we don't know about then we can't really help. If it's a standard TextBox then you already have all you need from us. If you aren't willing to read the documentation for a property when someone refers you to it then that's up to you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    OK JM. Thanks for the help. By the way, it is absolutely not a custom control. I am curious as to what this helpful and comprehensive documentation is that you are referring to though JM? Certainly I looked up the information on the properties you suggested. The information provided........ nothing.

  10. #10
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    743

    Re: Get rid of Highlights

    GW

    I'm a bit confused as to which controls you are referring

    1. Cyan
      • Change ID
      • Item Supplier ID
      • Change Type
      • e-File Directory Path
    2. Blue
      • Title Name
      • Item Owner
      • Item Manager
      • Where Used


    Could you clarify

    Spoo

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,578

    Re: Get rid of Highlights

    Quote Originally Posted by gwboolean View Post
    Certainly I looked up the information on the properties you suggested. The information provided........ nothing.
    Either you don't know how to look, you don't know how to use simple information or your issue is caused by something unrelated. The documentation for the HideSelection property would have told you that it can be set to True, in which case selected text is not highlighted when the control does not have focus, or to False, in which case selected text will be highlighted when the control does not have focus. I'm not sure how much simpler it could be.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12
    Fanatic Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    565

    Re: Get rid of Highlights

    Quote Originally Posted by gwboolean View Post
    OK JM. Thanks for the help. By the way, it is absolutely not a custom control. I am curious as to what this helpful and comprehensive documentation is that you are referring to though JM? Certainly I looked up the information on the properties you suggested. The information provided........ nothing.
    well the Form Load Code would help to see what's going on.

    here some Code to check your Control properties ..
    start with the first Textbox
    Code:
    Imports System
    Imports System.Drawing
    Imports System.Windows.Forms
    Imports System.Reflection
    
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'place your textbox here
            Call EnumObjectProperties(TextBox1, ListBox1)
        End Sub
    
        Private Sub EnumObjectProperties(ByVal ctrl As Object, ByRef lb As ListBox)
            Dim Item As PropertyInfo
            Dim gt As Type = ctrl.GetType
    
            For Each Item In gt.GetProperties(BindingFlags.Public Or BindingFlags.Instance)
                Dim hObject As Object
                If Item.CanRead Then
                    Try
                        hObject = Item.GetValue(ctrl, BindingFlags.Public Or BindingFlags.GetProperty, Nothing, Nothing, Nothing)
                        lb.Items.Add(Item.Name & " > " & hObject.ToString())
                    Catch ex As Exception
                        lb.Items.Add(Item.Name & " > " & "can't get Value")
                    End Try
                End If
            Next
        End Sub
    or try this..
    (but this is really cheating yourself with a workaround)

    Code:
     Private Shared Sub ClearTB(ByRef frm As System.Windows.Forms.Form)
            For Each ctrl As Control In frm.Controls
                If TypeOf ctrl Is TextBox Then
                    DirectCast(ctrl, TextBox).SelectionStart = 0
                End If
            Next
        End Sub
    
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Call ClearTB(Me)
        End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    30,824

    Re: Get rid of Highlights

    As a simple test, I'd implement the Shown event handler for the form and set the focus explicitly to one of the textboxes. I feel like you could replicate this behavior on certain types for forms, but it wouldn't be easy, so you certainly didn't do it by accident. If setting the focus, or explicitly selecting one textbox, changes the appearance, then...you haven't fixed a thing, but it might give you some place to start.
    My usual boring signature: Nothing

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Either you didn't bother thinking it through or you are just intentionally being obtuse. Yes JM, I did read the information. Yes JM I set to both true and false and yes JM the information provided almost nothing of use. I am not sure how much simpler that could be.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Spooman,

    The controls I am referring to is a single textbox (title/Name) and the three comboboxes. All of these controls already had data in them prior to the load event. Additionally, in running the app, I have noticed that only those controls behave that way. Furthermore, these same controls, if empty, are not highlighted after the load event. Anyway, here is the pertinent code for the load event:

    Code:
                    Try
                        Me.LnkChangeRequestTableAdapter.FillByChangeNum(Me._MasterBase4_0ItemMasterDataSet.lnkChangeRequest, glbintCRNum)
                        glbstrBaseCategory = Me._MasterBase4_0ItemMasterDataSet.lnkChangeRequest(0).strMasterBaseType
                        DisplayAdmin()
    DisplayAdmin is a sub routine used to set properties on the form for a particular usage. For this usage the settings below define the properties for the controls of interest. No other property settings, in the properties window, were set to anything different than the default settings.

    Code:
            With txtTitle
                .BackColor = Color.Snow
                .ReadOnly = False
                .TabStop = True
                .TabIndex = 0
            End With
            With txtRev
                .BackColor = Color.Snow
                .ReadOnly = False
                .TabStop = True
                .TabIndex = 1
            End With
            'grpChangeRequest
            With lblChangeType
                .BackColor = Color.LightSteelBlue
                .Enabled = False
                .TabStop = True
                .TabIndex = 2
            End With
            With cmbOwner
                .BackColor = Color.Snow
                .Enabled = True
                .TabStop = True
                .TabIndex = 3
            End With
            With cmbManager
                .BackColor = Color.Snow
                .Enabled = True
                .TabStop = True
                .TabIndex = 4
            End With
            With cmbWhere
                .BackColor = Color.Snow
                .Enabled = True
                .TabStop = True
                .TabIndex = 5
            End With

  16. #16
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    Hi, this is a weird one....
    I wonder if HideSelection in the textboxes proprety window its set to false?
    Last edited by Mike Storm; Oct 4th, 2017 at 10:14 AM.

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    I have been looking through what I have on this form and it has become obvious that the .tabstop settings in some way relates to this. There are three containers that contain controls that have .TabStop = True and the containers .TabIndex are set to 0, 1 and 2 respectively (Change Information groupbox, Change Request groupbox and Change Order groupbox). Within the group boxes I have set the .TabIndex in the order I would like tabbing to occur.

    Since the textbox (labeled Title/Name) is in the container with the lowest .TabIndex and since it has the lowest setting in that container it is where the cursor will be when the form is loaded. I expect that to be highlighted (although I would prefer no highlights at all). So the question is, why are all three of the comboboxes in the second container highlighted?

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Mike,

    I have played around a little bit with the HideSelect property and have noticed no difference in behavior whether set to False or True. The fact is that all of the controls have the default setting for this, which is True. Of course that doesn't mean that I am wrong and there are some that might have been set accidentally. I am looking through everything as we speak to see if that might be the case.

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    It has become apparent that the whole issue seems to be with the comboboxes. Based on a little experimentation I have found that if the .TabStop = True, for any combobox, it will be highlighted. And conversely, if the .TabStop = False for any combobox it will not be highlighted. I had not noticed this in the past because I did not usually set .TabStop = True for comboboxes. While I would like to know why this behavior occurs, it seems that the easy course is just to not tab through the comboboxes.

  20. #20
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    It will be related to your code or propertyes set in the property window, i use tabstop on mine, actualy my forms normaly have KeyPreview set to true, and i supress Enter key and use send key {TAB}, so that when the user presses enter in a combo or in a textbox insted of hear the anoing sound, the sound is supressed and it moves to the next control.

  21. #21
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    Another way to test that, and as a wild guess what i think is happening there is that somewhere in you code you are setting the value of does combos using comboname.selectedindex/comboname.selectedtext=something, you can add a combobox and bind it to the same as where used one in your form, and see if it does the same.
    Last edited by Mike Storm; Oct 4th, 2017 at 11:09 AM. Reason: i ment test, not text... my bad spealing

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Mike,

    I did check all of the HideSelection properties for all of the controls in the properties window. They were all set to True. Comboboxes do not have this property. Funny thing, I have never used the Enter Key and always use the Tab Key when moving through controls. This is even true when I am using any application at anytime. I never even noticed that I did that. I guess that is why I never hear any sound (it would be annoying).

    I tried it with the KeyPreview set to True and the comboboxes are all still highlighted if the .TabStops are set to True.

  23. #23
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    Keypreview will not solve that issue, was just to give u a exemple that its not TABStop that is doing that.
    Is there any code seting the value of does combos?

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    I think you got me Mike. I do set the comboboxes to .SelectedIndex = -1 in the code in a single sub routine where I am generating a new change request. However, this subroutine is not called in the sequence that I am running here. I do not see how that could have an effect.

    The comboboxes are bound though. They are bound to what I call lookup tables (I use these instead of collections). Each of them has their .Text set to the change request table.

  25. #25
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    a way to check that is to add a new combo, bind it to the same value as the "Where used" for exemple, and do not add any other code, ans see what it does.

    As for the fact that you like to style each control, an alternative that will save you many lines of code is to have a Module in you app, name it for exemple MyControlStyles, and in this module create a sub for each style:
    Code:
    Module yControlStyles
    
    Sub DGV_READONLY(MyDGV as Datagridview)
    
    With MyDGV
    .Readonly=true
    'And subsequente properties you wnat to set
    End With
    
    End Sub
    
    Sub MyBlueTextbox(MyTextBox as textbox)
    With MyTextBox 
    .backcolor =color.Red
    'And subsequente properties you wnat to set
    End With
    
    end sub
    
    End Module
    
    'Then under you form load event you only need to 
    
    Private Sub Yourform_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
    MyBlueTextbox(textbox1)
    
    end sub

  26. #26
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    743

    Re: Get rid of Highlights

    GW

    OK, so we've narrowed it down to the ComboBoxes ("blue" set of controls)

    Truth be told, I don't have VB.Net
    But, FWIW, I noticed a similar behavior with VB6
    • If TabStop = True .. get a blue highlight
    • If TabStop = False .. don't


    Spoo

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    261

    Re: Get rid of Highlights

    Thanks Spoo.

    Mike, I am going to have to drop this for awhile. Just got a phishing call about ICloud and data and they want me to call them back (damn sure won't). I need to spend some time going through and making sure that whomever they are that they are not already into my computer. As soon as I get the chance I will do as you suggested and see what occurs. Later man.

  28. #28
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: Get rid of Highlights

    Quote Originally Posted by Spooman View Post
    GW

    OK, so we've narrowed it down to the ComboBoxes ("blue" set of controls)

    Truth be told, I don't have VB.Net
    But, FWIW, I noticed a similar behavior with VB6
    • If TabStop = True .. get a blue highlight
    • If TabStop = False .. don't


    Spoo
    You right, but only when you set its value, once it loses focus by default will become white again.
    Another option to prevent it of ever be highlighted is to set DropDownStyle = DropDownList, instead of its default value DropDown what has another advantage or disavantege depending on whats the goal, by doing this he will prevent the user from inser data to the combo and limit it to the values in the list.

  29. #29
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,578

    Re: Get rid of Highlights

    Quote Originally Posted by gwboolean View Post
    Either you didn't bother thinking it through or you are just intentionally being obtuse.
    No, I thought it through the whole way and you are being unintentionally obtuse.
    Quote Originally Posted by jmcilhinney View Post
    Either you don't know how to look, you don't know how to use simple information or your issue is caused by something unrelated.
    Quote Originally Posted by gwboolean View Post
    Yes JM, I did read the information. Yes JM I set to both true and false and yes JM the information provided almost nothing of use.
    Except the information was of use because you have now confirmed, exactly as I said, that your issue is caused by something else. If you don't think that ruling out a cause is a step in solving a problem then that is part of your problem to begin with.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.