• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Binding to a label in windows form

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
TimSweet220
Asked:
TimSweet220
  • 3
  • 2
1 Solution
 
alainbrydenCommented:
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
 
t_itaniumCommented:
what is DsPathway1.Pathway.text?? any way?/
0
 
TimSweet220Author Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
alainbrydenCommented:
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
 
TimSweet220Author Commented:
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
 
alainbrydenCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now