Results 1 to 8 of 8

Thread: [RESOLVED] Trimming bound controls values

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Resolved [RESOLVED] Trimming bound controls values

    i have text- & comboboxes displaying char(255) data from SQL Server database.
    if i input value with length 50 chars and press "Save", 205 blanc spaces are added (255 minus trimmed value's length) at the end.

    how to enable text- and comboboxes to show trimmed values (w/out editing records)?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Re: Trimming bound controls values

    ...maybe datatable control has any property to make char values trimmed?
    and is it possible to trim items of bound combobox manually?

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

    Re: Trimming bound controls values

    A bound control displays the data it is bound to, plain and simple. Perhaps you could add an extra column to your DataTable to contain the trimmed values which can be bound to the controls, then just transfer the values to the other column as needed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Question Re: Trimming bound controls values

    Re.: plain and simple:
    yes, it is.

    Re.:extra column:
    i have already expression columns.
    adding a new extra column per each text column would enlarge my project which is more than enough large (pls see my other threads - they are all related on the same project).

    maybe i need to change data type of column in dataset or in MS SQL Server table ("string(255)" and "char(255)" now)?

    i need 255 to be MAX length of a string, not FIXED one.
    pls advise if you can.

    Quote Originally Posted by jmcilhinney
    A bound control displays the data it is bound to, plain and simple. Perhaps you could add an extra column to your DataTable to contain the trimmed values which can be bound to the controls, then just transfer the values to the other column as needed.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Re: Trimming bound controls values

    is there any data type with limited but without fixed length?

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Trimming bound controls values

    varchar....

    -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??? *

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Question Re: Trimming bound controls values

    Many thanks techgnome,

    Pls advise if changing data type from char to varchar in MS SQL Server database causes error in my program?
    do i need to reconfigure adapters (vs2005 beta2) and/or make any changement in bindingsources?

    sorry, i can try but the project is TOO slow in design mode so advise if have time...

    Quote Originally Posted by techgnome
    varchar....

    -tg

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    99

    Re: Trimming bound controls values

    thanks again to techgnome.
    resolved.

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