有关Combo Box的问题,help!

bobofu 2001-04-29 10:43:00
当我在组合框中选中一个项目时,如何知道该项目是第几个?
就是说ComboBox是不是按数组的方式组织项目的?
ComboBox有没有这个函数?
...全文
102 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
surfy_21 2001-09-25
  • 打赏
  • 举报
回复
up
fatty 2001-04-30
  • 打赏
  • 举报
回复
bobofu 2001-04-30
  • 打赏
  • 举报
回复
现在我想知道,这个索引值是从0开始逐渐增加的吗?是不是ComboBox的列表框中第n个item,它的索引值就是n-1?
我是个新手,请大家帮帮忙,谢谢。
谢谢masterz.
masterz 2001-04-29
  • 打赏
  • 举报
回复
Example

// The pointer to my combo box.
extern CComboBox* pmyComboBox;

// Select the next item of the currently selected item
// in the combo box.
int nIndex = pmyComboBox->GetCurSel();
int nCount = pmyComboBox->GetCount();
if ((nIndex != LB_ERR) && (nCount > 1))
{
if (++nIndex < nCount)
pmyComboBox->SetCurSel(nIndex);
else
pmyComboBox->SetCurSel(0);
}

bobofu 2001-04-29
  • 打赏
  • 举报
回复
wolfzhu:能不能再说详细一点?谢谢
wolfzhu 2001-04-29
  • 打赏
  • 举报
回复
用SendDlgItemMessage()发送一个CB_GETCURSEL或LB_GETCURSEL消息
jsd198 2001-04-29
  • 打赏
  • 举报
回复
masterz()已经说了
1 , vb5dialog.zipThis demonstrates how to subclass the Common Dialog Dialogs and manipulate a specific Dialog.2 , cpnl.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).3 , vbo_progbar.zipImplement a common control progress bar with added features that are not accessable using COMCTL32.OCX! 4 , vbo_infolabel.zipThis control adds a great user-friendly interface with and icon and "Hover" ability. Based on a control seen in ICQ. 5 , vbo_checkcombo.zipAdd a checkbox to a combo box and use it to enabled/disable the combo! or whatever you would like to do with it! 6 , vbo_controlframe.zipCreate your own system button such as a Maximize, Minimize, Close, and many others with ease! 7 , vbo_ctextbox.zipThis class makes using the Textbox or Edit class API simple. Easily set properties and access many features not available directly from VB. 8 , taskbar.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).9 , NT_Service.zipThis is an OCX that allows you to create an NT service application...add the control to your project and register it as a service!!10 , Scroller.zipThis is a Control Container, it's like a frame control but it lets you scroll the content up and down...11 , TrayArea.zipThis control lets you add your icon to the System Tray Area and handle some events such as MouseMove, MouseDown, MouseUp and DblClick.12 , Resizer.zipThis is a very useful control: It's a container control, you can insert two controls inside and then you'll have a vertical (or horizontal) resizer bar (like the Windows File Explorer). A resizer can contain another resizer... an so on. (you can divide you form in as many sizable sections as you want...).13 , Label3D.zipTh
RX Library 2.75 =============== The Set of Native Delphi Components for Borland Delphi versions 1, 2, 3, 4 & 5 and Borland C++ Builder 1, 3 & 4. 100% Source Code. Last revision date Oct 12, 1999. PLEASE FOLLOW THE INSTRUCTIONS PROVIDED IN THE INSTALLATION SECTION! TABLE OF CONTENTS ----------------- Latest Changes Overview History License Agreement Installation Demonstration Programs Source Files Using GIF Images Copyright Notes NEW FOR VERSION 2.75 -------------------- Delphi 5.0 & C++Builder 4.0 Compatibility New components: TRxLoginDialog New properties, events: TFormPlacement.RegistryRoot TFormPlacement.Version TFontComboBox.UseFonts TRxDBGrid.OnTopLeftChanged TRxDBLookupCombo.DisplayValues TStrHolder.Macros, TStrHolder.OnExpandMacros RxSpin.TValueType.vtHex New routines, methods, constants: SaveClipboardToStream, LoadClipboardFromStream (clipmon.pas) AppFileName, AppVerInfo (rxverinf.pas) XorString, XorEncode, XorDecode (strutils.pas) BUG FIXES. Overview -------- RX Library contains a large number of components, objects and routines for Borland Delphi with full source code. This library is compatible with Borland Delphi 1, 2, 3, 4, 5 and Borland C++ Builder 1, 3, 4. This collection includes over 60 native Delphi components. RX Library is a freeware product. Feel free to distribute the library as long as all files are unmodified and kept together. The authors disclaim all warranties as to this software, whether express or implied, including without limitation any implied warranties of merchantability or fitness for a particular purpose. Use under your own responsibility, but comments (even critique) in English (or in Russian) are welcome. 1. Components: TRxDBLookupCombo provides an incremental search through lookup list by directly typing into the combo control while the lookup list is displayed, LookupSource can refer to TTable, TQuery, TRxQuery or TQBEQuery. It even incrementally searches on the query results and much more... TRx
1|)Security Wizard
Anyone that has set up Jet security on an application knows how difficult and confusing it can be. The Security Wizard is a tool that will allow you to setup your own security mechanism in your Access application without having to implement Jet security. Running the wizard from Tools/Add-ins/Security Add-In will copy several objects into your application. It will drop a table (tblOperators) into your application that will contains the list of users of your app and their password (passwords are encrypted using very simple XOR encryption.) Also, it will drop several modules, two class modules(GlobalProperties and SecurityClass) and one standard module (basMiscSecurityFunctions). (NOTE: The basMiscSecurityFunctions module has an IsLoaded function in it. If you already have an IsLoaded function in your application you will needed to delete if from the basMiscSecurityFunctions module. Delete the function only, not the whole module). Also, several forms are added to your project. Three of them (frmCreateUser, frmChangePassword, frmGetUserName) are used by the class module. The fourth form (frmEditUsers) can be used to manage the user accounts (make users administrators for example).
Once you run the Security wizards you add the following to the startup procedure of your application:
PWs.ConfirmPassword

Once the user logs in you can query there user name or authority using several GlobalProps properties as follows:
If GlobalProps.Administrator = True Then ...
or
If GlobalProps.CurrentUser = "JohnS" then ...

For more information the Security Add-In please click here or read the help file that is distributed with the wizards.

2) Global Error Handler
Error handling is a necessary evil of programming in ANY VB environment. All well-developed applications will have error handling code in most if not all of the procedures. The "evil" lies in the fact that VB does not add this error handling code for you. It only create the procedure "stub" (Sub...End Sub) for you so that it is up to the developer to add the error handling.
The Global Error Handler add-ins has two components. The first component, like the Security Add-In described above, adds all the objects that are needed to enable error handling and is installed from the Tools/Add-Ins/Global Error Handler menu item. This will add two(2) objects to your table: A table (usysErrors) which is the where all the errors are logged. (Yes - one of the features of thjs Add-In is that all errors get logged into this table which makes troubleshooting problems much easier.) And a module (basGlobalErrorHandler) which is procedure called by your handlers in order to handle and log the errors.

The second component is a "builder" that is installed by the setup routine. When you create a new procedure the builder will automatically add all of the error handling for it including the call to the Global Error Handler (which logs the error). To execute the builder, right click in the procedure and choose "Build" from the context menu. Now, instead of going straight to the Expression Builder, a selection box will appear. Choose "Global Error Handler" from the list and click OK. The error handling code will be automatically inserted into your procedure.

For more information on the Error Handling Add-Ins or error handling in general please click here or read the help file that is distributed with the wizards.

3)Many-to-Many Wizard
The Many-to-Many Add-In provides a way for developers to quickly and easily create forms that can be used to populate the junction table of a many-to-many table relationship. Normally, populating a junction table requires use of a Main-Form/Sub-Form interface with the junction table being populated by a Combo Box which is in the Sub-Form. (Don't know what I am talking about? Click HERE.) This kind of interface is extremely "kludgy" but it the only option available to non-programmers (unless they use some kind of Add-In such as the one described here.)
You start the Many-To-Many wizards (there are two of them) by selecting either Tools/Add-Ins/M2M CheckBox Wizard or Tools/Add-Ins/M2M ListBox Wizard from the menu. Each of these will step you through a wizard that will create a form for you (that you name at the end) that can then be used to populate the junction table with an form that is easy to use and intuitive. (NOTE: These wizards are the least tested of all of them and you probably WILL find bugs.)

For more information the Many-to-Many wizards or table relationships in general please click here or read the help file that is distributed with the wizards.

4) Name Builder
Microsoft Built-In wizards are very useful but they have one annoying flaw. That is, no naming conventions are used. Naming conventions are commonly used standards that all professional developers use to better manage their code and their projects. Even controls on forms should have standard naming conventions. For example, combo box usually begin with cbo (i.e., cboNames) and text boxes start with txt (i.e. txtAddress). When these conventions are used it makes managing the code associated with the controls easier.
The Microsoft wizards do NOT use these conventions. So when you create a form or report with the wizard, instead of "cboName" or "txtAddress" you get simply get "Name" or "Address". (This can cause some expressions to return #Name instead of the correct value, expecially in reports.) The problem is that it is difficult to remember the standard naming convention prefixes for controls and renaming them can be time consuming.

The Name Builder will correctly prefix a control with the right convention based on its type. To use it (the name builder is installed by the setup program) simply select the control and view its property sheet. Select the Name property from the property sheet. Click on the Build (...) button that is to the right of the property. It will take the current name that is in the property cell and replace it with the same value stripped of spaces and other undesirable text and prefixed with the right three letter convention.

Coming soon: A Name Builder wizard that will rename ALL controls on a new form using proper conventions. Send us an e-mail so that we can notify you when the change is available.


5) Linked Table Manager and other Wizards
Also included with the setup are a Linked Table Manager and other Add-Ins.

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧