Hi!
I have several textfiles on disk like:
Thing 1
Thing 2
etc...
On a form I have two combo-boxes. When user chooses from Combo1
(predefined items) I want the second combo-box to load the text files
according to which item user chooses in Combo1.
Is there anybody that know how I do this?
The reason why is because the textfiles contain so much text (and are
so many) I don't want to put it in the code like:
if Combo1.ListItem = 0 then
Me!Combo2.Items.Rowsource = "Thing 1;Thing 2; etc"
End if
The textfiles will also be altered from time to time, but will always
contain items belonging to Combo1.
Thanks!
Me.Name 8 3068
'Me!Combo2.Items.Rowsource = "Thing 1;Thing 2; etc"'
How bout you read the items from the text file into an output string
stream(or just append to a regular string) using a loop that gets each
line into the string and appends a ';', then assign the string to
RowSource.
If I were you though, I would create a table and paste the items from
the text file into the table, then you can use an SQL query for your
row source:
SELECT MyListOfOptions FROM MyTable;
If you ever want to edit the options available, then it's as easy as
editing the table.
Geir Baardsen wrote: Hi!
I have several textfiles on disk like:
Thing 1 Thing 2
etc...
On a form I have two combo-boxes. When user chooses from Combo1 (predefined items) I want the second combo-box to load the text files according to which item user chooses in Combo1.
Is there anybody that know how I do this?
The reason why is because the textfiles contain so much text (and are so many) I don't want to put it in the code like:
if Combo1.ListItem = 0 then
Me!Combo2.Items.Rowsource = "Thing 1;Thing 2; etc"
End if
The textfiles will also be altered from time to time, but will always contain items belonging to Combo1.
Thanks!
Me.Name
You can string them together as mentioned in another post. A problem
may occur since the string that can be concatenated is limited. I'm not
sure...it may be 2048 characters.
Check out RowSourceType and then find the info for creating a
UserDefinedFormat. Then you can have large sets of data...but you
should be able to program.
Hey Steve Jorgensen or Lyle,
can you do this kind of thing in ADO? basically, read a delimited
textfile into a recordset-type thing (virtual table, essentially) and
then assign the result as the rowsource for the combobox? I would
think that you could call it by doing something like
Function CreateList(byval strFileName as string) As ADODB.Recordset
.... or some such thing. pi********@hotmail.com wrote: Hey Steve Jorgensen or Lyle, can you do this kind of thing in ADO? basically, read a delimited textfile into a recordset-type thing (virtual table, essentially) and then assign the result as the rowsource for the combobox? I would think that you could call it by doing something like
Function CreateList(byval strFileName as string) As ADODB.Recordset ... or some such thing.
Surely the listbox simply translates the "recordset-type thing" to a
string anyway, so why would one translate the string to a recordset first?
Assuming you can read the textfile just set the row source type to
valuelist, and the rowsource to the string. I often do my list and combo
boxes this way even when they are based on a query.
--
--
Lyle
"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
In news:Eh*********************@read2.cgocable.net,
Lyle Fairfield <ly******@yahoo.ca> said: pi********@hotmail.com wrote: Hey Steve Jorgensen or Lyle, can you do this kind of thing in ADO? basically, read a delimited textfile into a recordset-type thing (virtual table, essentially) and then assign the result as the rowsource for the combobox? I would think that you could call it by doing something like
Function CreateList(byval strFileName as string) As ADODB.Recordset ... or some such thing.
Surely the listbox simply translates the "recordset-type thing" to a string anyway, so why would one translate the string to a recordset first? Assuming you can read the textfile just set the row source type to valuelist, and the rowsource to the string. I often do my list and combo boxes this way even when they are based on a query.
Isn't there a limit on the length that string can be?
--
regards,
Bradley
A Christian Response www.pastornet.net.au/response
Br@dley wrote: In news:Eh*********************@read2.cgocable.net, Lyle Fairfield <ly******@yahoo.ca> said:
Assuming you can read the textfile just set the row source type to valuelist, and the rowsource to the string. I often do my list and combo boxes this way even when they are based on a query.
Isn't there a limit on the length that string can be?
I can't comprehend a list box with so many choices that it approaches
any limit whatever, After 20 or so choices I find a different way. A
list box of a few thousand items is, IMO, quite ludicrous. SO my answer
is, "Dunno, Don't Care!".
There is a limit to the size of any list. Of course that's not including
the list of Texas executions which is infinite, but these are Divine
works of Men of God!
--
--
Lyle
"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Lyle Fairfield wrote: Br@dley wrote:
In news:Eh*********************@read2.cgocable.net, Lyle Fairfield <ly******@yahoo.ca> said:
Assuming you can read the textfile just set the row source type to valuelist, and the rowsource to the string. I often do my list and combo boxes this way even when they are based on a query.
Isn't there a limit on the length that string can be?
I can't comprehend a list box with so many choices that it approaches any limit whatever, After 20 or so choices I find a different way. A list box of a few thousand items is, IMO, quite ludicrous. SO my answer is, "Dunno, Don't Care!".
I agree a few 1000 items is overkill. 20 choices? What happens if you
have 21 items? A list/combobox can handle more easily enough.
If you have a few rows but lots of columns you run out of string space.
The best way to do it is to create a user defined function. Using a
string is useful for small numbers of rows/cols. There is a limit to the size of any list. Of course that's not including the list of Texas executions which is infinite, but these are Divine works of Men of God!
Guys,
Whatever happened to callback functions. These were all the rage with
Access 97. If they are still supported then you can supply the data to your
function any which way. The mvp site should have samples of these.
--
Alan Webb kn*******@SPAMhotmail.com
"It's not IT, it's IS"
"Geir Baardsen" <ge***********@hotmail.com> wrote in message
news:35**************************@posting.google.c om... Hi!
I have several textfiles on disk like:
Thing 1 Thing 2
etc...
On a form I have two combo-boxes. When user chooses from Combo1 (predefined items) I want the second combo-box to load the text files according to which item user chooses in Combo1.
Is there anybody that know how I do this?
The reason why is because the textfiles contain so much text (and are so many) I don't want to put it in the code like:
if Combo1.ListItem = 0 then
Me!Combo2.Items.Rowsource = "Thing 1;Thing 2; etc"
End if
The textfiles will also be altered from time to time, but will always contain items belonging to Combo1.
Thanks!
Me.Name This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pepehammer |
last post by:
Hi everybody!
I got a combobox to fill.
I want to display some information (Text), but when I select a item, I want
to return a number.
The info I want to fill in is something like this:
...
|
by: Maurice Mertens |
last post by:
Hi all,
In VB.NET you can set the DropDownStyle for a combobox to 'DropDown' or
'DropDownList'. When you set it to DropDownList, it supports auto-fill. But
when you set it to 'DropDown', the...
|
by: ken |
last post by:
I would like to fill a combobox with the values of one
column of the dataview I am using. When I set it up the
way I expect it would be, I get every row in the combobox
says: ...
|
by: sparkle |
last post by:
Hi Everybody,
I'm filling a combobox from a class, which works fine on it's own.
But when I insert code to fill in other controls something in the
combobox fill is causing the...
|
by: Sakharam Phapale |
last post by:
Hi All,
How to fill one ComboBox from other ComboBox control?
1) Only setting the reference does the trick but doesn't show items in
control. If you see in immediate window, it shows...
|
by: Simon Verona |
last post by:
I posted this in dotnet.languages.vb.controls but thought I'd post here as
well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table...
|
by: hung tran |
last post by:
Hi,
I'd like to drop down a combobox after validating the Leave() event, how
can I do that ?
Thanks
|
by: Tark Siala |
last post by:
hi dear
i'm programmer with VB6, but now i starting with C#.
first problem is coming when i need fill "ComboBox Control", as you know
when i fill combobox in VB6 by this code:
comboX.AddItem...
|
by: Crazy Cat |
last post by:
Hi all,
I have combobox that is bound to a custom object collection thusly
Dim collection As List(Of StructureType) =
StructureType.FindStructureTypes(SharedObjects.StructureTypes,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |