Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,415 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,854 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



select first row in combobox from other form

 
Reply to this topicStart new topic

select first row in combobox from other form

Hanzie
post 22 Jun, 2008 - 03:56 AM
Post #1


D.I.C Head

**
Joined: 19 Aug, 2007
Posts: 86


My Contributions


Hello, on a form i have a combobox bound to a database-table.

On another form i have a code which makes a ms-word document.

What i want is that the second form selects the first row from the combobox-index and displays it in the word document.

I have this working, but it only works when i visit the first form first, then go to the second form and run the code to display the ms-word document.

It doesn't work when i run the second form first???????

Here is some code I use:

first-form code (frminstellingen):
CODE

Private Sub FrmInstellingen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DocRegData2DataSet.Gebruikers' table. You can move, or remove it, as needed.
        Me.GebruikersTableAdapter.Fill(Me.DocRegData2DataSet.Gebruikers)

        Me.GebruikersnaamComboBox.SelectedIndex = 0

    End Sub


second-form code:
CODE

orange.Text = "E-mail:" & ControlChars.Tab & My.Forms.FrmInstellingen.GebruikersnaamComboBox.Text


It seems it only loads the data in the combobox on the first form when i visit the form. But when i enter the same code as under frm_load event in the second form it still doesn't work?!

Strange he??

Any help?!
User is offlineProfile CardPM

Go to the top of the page


Hanzie
post 26 Jun, 2008 - 10:23 AM
Post #2


D.I.C Head

**
Joined: 19 Aug, 2007
Posts: 86


My Contributions


mad.gif

Can someone please help me.

It seems like my combobox on a windows-form isn't loaded directly?

I have the folowing code for displaying the selected text from a combobox on another form:
CODE

Me.TextBox1.Text = My.Forms.FrmInstellingen.GebruikersnaamComboBox.Text


The code on the form where the combobox:

CODE

Public Class FrmInstellingen

    Private Sub FrmInstellingen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DocRegData2DataSet.Gebruikers' table. You can move, or remove it, as needed.
        Me.GebruikersTableAdapter.Fill(Me.DocRegData2DataSet.Gebruikers)

end sub


The first time there is no textvalue displayed on the textbox1.

When i visit the form "instellingen" where the combox is and then return to the form where the textbox is then the text from the combobox is being displayed on textbo1.

Why not when i go directly to the form with the textbox??

PLEASE HELP. It's driving me nuts!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/20/08 05:58AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month