Solved

Binding to a label in windows form

Posted on 2006-06-22
6
243 Views
Last Modified: 2010-04-17
Below is my code for a function that fills a dataset and then calling the function to display the text.

However nothing displays.  I've used the propert explorer to set the text properties of the label..but that might be my problem.

Public Sub GetPathway(ByVal vABR_ID$)
          SqlDataAdapter_Pathway.SelectCommand.Parameters("@ABRID").Value = vABR_ID$
        SqlDataAdapter_Pathway.Fill(DsPathway1)
 
  End sub
 
  Private Sub GetPathway()
        Dim Pathway As String
        Dim IMG As Boolean
        If IMG = "1" Then
            lblPathway.Text = "IMG" & "DsPathway1.Pathway.text"
        Else
            lblPathway.Text = "DsPathway1.Pathway.text"
        End If
    End Sub

Thanks in advance.

0
Comment
Question by:TimSweet220
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 16961789
Make sure that the properties "Word Wrap"= False and "Autosize"=True, otherwise your label may be putting your text right off the visible area.

Also, if you want the text to = DsPathway1.Pathway.text, then you need to get rid of the quotation marks, otherwise you won't see the data you are trying to look at, you will only exactly what's contained in the quotation marks.
0
 
LVL 5

Expert Comment

by:t_itanium
ID: 16966485
what is DsPathway1.Pathway.text?? any way?/
0
 

Author Comment

by:TimSweet220
ID: 16970415
The .text should be there.

DsPathway1 is the dataset that pulls over two field  IMG and Pathway (database fields)

so my attempt was to se the lblPathway to the text of the field Pathway in the dataset  Pathway1.

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 20

Expert Comment

by:alainbryden
ID: 16970531
Is the problem still occuring after making the adjustments I mentioned? I'm positive that those quotation marks shouldn't be surrounding the Pathway references.
0
 

Author Comment

by:TimSweet220
ID: 16970846
HEre is my code now.

Still not displaying but I'm not sure of the problem..  

Public Sub GetPathway(ByVal vABRID$)
        Dim Pathway As String
        Dim IMG As Boolean
        SqlDataAdapter_pathway.SelectCommand.Parameters("@ABR_ID").Value = vABRID$
        SqlDataAdapter_pathway.Fill(DsPathway1)

        If IMG = True Then
            lblPathway.Visible = True
            lblPathway.Text = "IMG" & Pathway
        ElseIf IMG = False Then
            lblPathway.Visible = True
            lblPathway.Text = Pathway
        Else
            lblPathway.Visible = False

        End If
    End Sub
0
 
LVL 20

Accepted Solution

by:
alainbryden earned 500 total points
ID: 16971335
Try this before anything:

lblPathway.Visible = true
lblPathway.Text = "Before"

See if that displays. If nothing is displaying, then I'm guesing the reason is that IMG is always false, and that the String 'Pathway' which you never seem to have set anywhere in there, is an empty string, so there is nothing to display.

also note that your ELSE statement will never be run, because IMG is always either true or false, so you can remove it entirely.

If the original
lblPathway.Visible = true
lblPathway.Text = "Before"
doesn't cause anything to be displayed, then you need to do a few things:
1. Make sure the properties I mentioned before are set appropriately
2. Make sure that nothing immediately following this method sets the lblPathway label visibility to false, or clears it before you get the chance to see it.
3. Make sure you are referencing the correct label, that it is placed visibly, and that it is wide enough to display the text.

If all of that fails then we have to look at how your method is called and what data members you have.

Another little hint is that often, when things aren't working for one reason or another, you can force the program to smarten up by adding the line:
DoEvents
to your code. It just seems to work in some weird situations. Especially when it comes to updating a form display.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
python question 5 76
Adding Namespace to the second node of the xml 16 71
"Black Box" Testing of Control System Software 2 48
VB.net and sql server 4 33
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now