Solved

Binding to a label in windows form

Posted on 2006-06-22
6
241 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wefewf 2 43
find a node in VST 2 46
allStar challenge 1 41
Tembedded WB animatid gifs not animated on some pcs 2 30
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 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

14 Experts available now in Live!

Get 1:1 Help Now