Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file
Populate combo box from txt file Populate combo box from txt file
Populate combo box from txt file
Go Back  Xtreme Visual Basic Talk > > > Populate combo box from txt file


Reply
 
Thread Tools Display Modes
  #21  
Old 06-21-2006, 10:54 AM
MikeJ's Avatar
MikeJPopulate combo box from txt file MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default


My mistake, I was just using what you said the error message was. Wherever the line that gives you that exception, you should stick either a .ToString() at the end of it, or use CStr as Baaklar suggested.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #22  
Old 06-21-2006, 11:08 AM
flipside82 flipside82 is offline
Regular
 
Join Date: Nov 2003
Posts: 73
Default sorry about the attachment.

well, I'm kinda making progress. instead of getting an error I get "System.Data.DataRowView" in the text box when I push the button instead of the actual name from the combo box. I attached my project. Just copy the alert.mdb to your local c: and see if it works.
Attached Files
File Type: zip test.zip (11.2 KB, 6 views)

Last edited by flipside82; 06-21-2006 at 12:36 PM. Reason: Please don't attach files with binaries (exe, dll, etc.)
Reply With Quote
  #23  
Old 06-21-2006, 01:09 PM
Baaklar Baaklar is offline
Centurion
 
Join Date: Mar 2003
Location: Omaha, Nebraska
Posts: 197
Default Solution

Code:
TextBox1.Text = cmbUsers.Text

The way I discovered it was to run in debug mode, and stop the execution at the above line. Then in the immediate window:


Code:
? cmbusers
{System.Windows.Forms.ComboBox}
    AccessibilityObject: {System.Windows.Forms.Control.ControlAccessibleObject}
    AccessibleDefaultActionDescription: Nothing
    AccessibleDescription: Nothing
    AccessibleName: Nothing
    AccessibleRole: Default
    AllowDrop: False
    Anchor: 5
    BackColor: {System.Drawing.Color}
    BackgroundImage: Nothing
    BindingContext: {System.Windows.Forms.BindingContext}
    Bottom: 72
    Bounds: {System.Drawing.Rectangle}
    CanFocus: True
    CanSelect: True
    Capture: False
    CausesValidation: True
    ClientRectangle: {System.Drawing.Rectangle}
    ClientSize: {System.Drawing.Size}
    CompanyName: "Microsoft Corporation"
    Container: Nothing
    ContainsFocus: False
    ContextMenu: Nothing
    Controls: {System.Windows.Forms.Control.ControlCollection}
    Created: True
    Cursor: {System.Windows.Forms.Cursor}
    DataBindings: {System.Windows.Forms.ControlBindingsCollection}
    DataSource: {System.Data.DataView}
    DefaultBackColor: {System.Drawing.Color}
    DefaultFont: {System.Drawing.Font}
    DefaultForeColor: {System.Drawing.Color}
    DisplayMember: "users"
    DisplayRectangle: {System.Drawing.Rectangle}
    Disposing: False
    Dock: None
    DrawMode: Normal
    DropDownStyle: DropDown
    DropDownWidth: 181
    DroppedDown: False
    Enabled: True
    Focused: False
    Font: {System.Drawing.Font}
    ForeColor: {System.Drawing.Color}
    Handle: 1902336
    HasChildren: False
    Height: 21
    ImeMode: NoControl
    IntegralHeight: True
    InvokeRequired: False
    IsAccessible: False
    IsDisposed: False
    IsHandleCreated: True
    ItemHeight: 13
    Items: {System.Windows.Forms.ComboBox.ObjectCollection}
    Left: 31
    Location: {System.Drawing.Point}
    MaxDropDownItems: 8
    MaxLength: 0
    ModifierKeys: None
    MouseButtons: None
    MousePosition: {System.Drawing.Point}
    Name: "cmbUsers"
    Parent: {WindowsApplication3.Form1}
    PreferredHeight: 20
    ProductName: "Microsoft (R) .NET Framework"
    ProductVersion: "1.1.4322.2032"
    RecreatingHandle: False
    Region: Nothing
    Right: 212
    RightToLeft: No
    SelectedIndex: 2
    SelectedItem: {System.Data.DataRowView}
    SelectedText: ""
    SelectedValue: {System.Data.DataRowView}
    SelectionLength: 0
    SelectionStart: 0
    Site: Nothing
    Size: {System.Drawing.Size}
    Sorted: False
    TabIndex: 0
    TabStop: True
    Tag: Nothing
    Text: "Lucas Moore"
    Top: 51
    TopLevelControl: {WindowsApplication3.Form1}
    ValueMember: ""
    Visible: True
    Width: 181
    WindowTarget: {System.Windows.Forms.Control.ControlNativeWindow}
The value of Text contained the value I selected, notice that .SelectedText is empty.

Someone with more knowledge than I can explain why it's like this - if you were to have loaded the combobox from an arraylist instead of a dataview, then .SelectedText would have contained the value you want. Not sure why the source of the data matters, but apparently it does.

cmbUsers.text is your answer though.
__________________
The first one in, the last one out, and if the gods permit, the last one standing.
Reply With Quote
  #24  
Old 06-21-2006, 01:36 PM
flipside82 flipside82 is offline
Regular
 
Join Date: Nov 2003
Posts: 73
Default

Wow, I feel kinda stupid now. Thanks so much for the time you spent on that. I really appreciate it alot. Much thanks.
Reply With Quote
  #25  
Old 06-21-2006, 03:07 PM
Baaklar Baaklar is offline
Centurion
 
Join Date: Mar 2003
Location: Omaha, Nebraska
Posts: 197
Default

You're welcome.

Don't feel stupid either - I can't explain why the combobox's properties are different based on what loaded it, only how I derived to your answer that fixed your program.

Any gurus out there care to explain or show a link(s) concerning this particular topic (might consider starting a new thread if you do).

MKoslof where are you!?? I know he knows.
__________________
The first one in, the last one out, and if the gods permit, the last one standing.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file Populate combo box from txt file
Populate combo box from txt file
Populate combo box from txt file
 
Populate combo box from txt file
Populate combo box from txt file
 
-->