By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,685 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,685 IT Pros & Developers. It's quick & easy.

Fill Drop-Downs question

P: n/a
I have a question about technique with regard to filling drop downs.

I have a Winform that has several different tabs and tables associated with
it. In an effort to keep the load time small I would like to not fill the
fields with lookups at form load time. I have a grid on a tab of this form
that has six fields in it that have lookups associated with them. By
lookups I mean that the dropDown in the field is populated by doing a query
on a lookup table. When is the best time to populate (fill) these lookup
fields?

I am thinking that perhaps I could do this when the grid is moved-to like in
an Enter of GotFocus event. For this particular form, the user must
explicitely place himself in edit mode by selecting a button on a toolbar.
Perhaps I could have code (say in the got focus event for the grid) that
says in effect "If the user is in edit mode, run the code that fills the
various lookup fields". I don't really know the best way to deal with this
but to finish off my supposition. If I did the above, I would like for the
code not to run if the fields have already been filled. Perhaps I should
create a global boolean variable for the form called IveAlreadyFilledGridX
and set it to true once the grid has been filled.

If anyone has any suggestions I would appreciate a response.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Not sure if this is what you want but I use a technique to fill a combobox
using the Enter event:

Private Sub cboCatalog_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboCatalog.Enter
Dim objDAO As New DAO(connString) 'my data access class with the ADO
commands in it.
Dim dv As DataView
Try
Cursor.Current = Cursors.WaitCursor
'remove old data
If dsMass.Tables.Contains("dtCatalog") = True Then 'dsMass is a
form level variable
dsMass.Tables.Remove("dtCatalog")
End If

strSQL = "SELECT * FROM Table1"

objDAO.FillTable(dsMass, "dtCatalog", strSQL, DBtype)
dv = (dsMass.Tables("dtCatalog")).DefaultView
dv.Sort = "descr"
With Me.cboCatalog
.DataSource = dv
.DisplayMember = "descr"
.ValueMember = "catalog"
.SelectedIndex = -1
End With
Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source & " - " & ex.TargetSite.Name,
MessageBoxButtons.OK, MessageBoxIcon.Information)
Finally
objDAO = Nothing
Cursor.Current = Cursors.Default
End Try

End Sub
--
Joe Fallon


"Woody Splawn" <wo***@splawns.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
I have a question about technique with regard to filling drop downs.

I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I would like to not fill the
fields with lookups at form load time. I have a grid on a tab of this form that has six fields in it that have lookups associated with them. By
lookups I mean that the dropDown in the field is populated by doing a query on a lookup table. When is the best time to populate (fill) these lookup
fields?

I am thinking that perhaps I could do this when the grid is moved-to like in an Enter of GotFocus event. For this particular form, the user must
explicitely place himself in edit mode by selecting a button on a toolbar.
Perhaps I could have code (say in the got focus event for the grid) that
says in effect "If the user is in edit mode, run the code that fills the
various lookup fields". I don't really know the best way to deal with this but to finish off my supposition. If I did the above, I would like for the code not to run if the fields have already been filled. Perhaps I should
create a global boolean variable for the form called IveAlreadyFilledGridX
and set it to true once the grid has been filled.

If anyone has any suggestions I would appreciate a response.

Nov 20 '05 #2

P: n/a
Hi Woody,

Base on my understanding, you have a form and 6 combo boxs on that form.
And you want to populate the combobox at runtime when the according
combobox got focus. There is also a button on the toolbar which indicate if
it is needed to populated. Or you have a datagrid with 6 dropdown on a form

Did I misunderstand your meaning?

Here is simple sample.
.NET Samples - Windows Forms: Data Binding
http://msdn.microsoft.com/library/de...us/cpqstart/ht
ml/cpsmpnetsamples-windowsformsdatabinding.asp

My suggestion is that the solution is based on when the data you want to
query will vary.
If the data is persisted all the time, then you may compile it into a
datafile.
If persisted in the application lifetime, you may load it when the
application is started, if the data is too big you may need to load a part
of them first.
If the query will change every time you change the query value then I think
your solution is good.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Woody Splawn" <wo***@splawns.com>
Subject: Fill Drop-Downs question
Date: Thu, 9 Oct 2003 14:22:34 -0700
Lines: 24
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OC**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:145518
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I have a question about technique with regard to filling drop downs.

I have a Winform that has several different tabs and tables associated with
it. In an effort to keep the load time small I would like to not fill the
fields with lookups at form load time. I have a grid on a tab of this form
that has six fields in it that have lookups associated with them. By
lookups I mean that the dropDown in the field is populated by doing a query
on a lookup table. When is the best time to populate (fill) these lookup
fields?

I am thinking that perhaps I could do this when the grid is moved-to like inan Enter of GotFocus event. For this particular form, the user must
explicitely place himself in edit mode by selecting a button on a toolbar.
Perhaps I could have code (say in the got focus event for the grid) that
says in effect "If the user is in edit mode, run the code that fills the
various lookup fields". I don't really know the best way to deal with this
but to finish off my supposition. If I did the above, I would like for the
code not to run if the fields have already been filled. Perhaps I should
create a global boolean variable for the form called IveAlreadyFilledGridX
and set it to true once the grid has been filled.

If anyone has any suggestions I would appreciate a response.


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.