Results 1 to 8 of 8

Thread: Combobox bound to dataset [Resolved}

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Combobox bound to dataset [Resolved}

    Hi,

    I have just had a problem getting a combobox to correctly display bound data.

    Eventually I discovered that when specifying the DisplayMember property, I had to use the exact case used in the spelling of the database field. If I use the wrong case for any letter I the displayed item was "System.Data.DataRowView"

    Is this normal?
    Last edited by taxes; Feb 27th, 2004 at 05:02 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yes the databinding needs to be case sensitive that includes DisplayMember, ValueMember and others like them.

    I believe Databinding uses reflection to display the choosen property and reflection is by default case sensitive. Here is an example:
    VB Code:
    1. 'this assumes a button named btnReflect and a textbox named txtMember
    2. 'when the button is clicked it displays the value of the member named in the textbox
    3. '(i.e. "Text" would equal the text for the button or in my case "&Reflect")
    4. 'Notice that it is by default case sensitive so "text" will return the type "Windows.Forms.Button"
    5.     Private Sub btnReflect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReflect.Click
    6.         MsgBox(String.Format("Property ""{0}"" equals ""{1}""", txtMember.Text, ReflectMember(btnReflect, txtMember.Text).ToString))
    7.     End Sub
    8.  
    9.     Public Function ReflectMember(ByVal obj As Object, ByVal member As String) As Object
    10.         'get propery
    11.         Dim pi As Reflection.PropertyInfo = obj.GetType.GetProperty(member)
    12.         If pi Is Nothing Then
    13.             Return obj.GetType.ToString
    14.         Else
    15.             Return pi.GetValue(obj, Nothing)
    16.         End If
    17.     End Function

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Combo Box Bound to dataset[ Resolved]

    Hi Edneeis,

    Many thanks. I certainly have not seen any comment to this effect in my books or MSDN (although I suspect it is there somewhere!)

    If you see this, Could you please tell me how I can mark this thread "Resolved". I've tried every way I can think of, so it must be too obvious
    Last edited by taxes; Feb 27th, 2004 at 12:12 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    To mark a thread resolved you have to edit your original post that started the thread and change its title to include [Resolved].

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Combo box bound to dataset [Resolved]

    Hi Edneeis,

    I.ve tried that - I think!!

    If you notice my previous post - and this one I hope - I have added [Resolved] to the subject box, but it has not registered in the forum page.

    I take it that I should make the entry in the "Post Subject" box on the top left where it is marked "optional"?

    I have used square brackets around "Resolved".
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You don't have to use brackets if you don't want. The thing is you put it in the Post Subject of your Reply but you have to go to your original post (the first one at the top of the thread) and press 'Edit' and then change that 'Post Subject' line. Then it will show in the list.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi Edneeis,

    Wow! At last.


    Many thanks.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No Problem. I was mystified about how they marked them resolved for a while too.

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