请问:怎样在窗体加载时创建9百9十9万9千9百9十9个(9999999)个CheckBox控件并显示出来。
用代码创建。
我做了一个
运行了半个多小时那个窗体都还没有显示出来。
有谁有更好的跟快的解决办法吗?
大哥大姐们帮忙呀!谢谢!

解决方案 »

  1.   

    按住shift,在窗体上点9百9十9万9千9百9十9个(9999999)下
      

  2.   

    9986
    9987
    9988
    未处理的“System.ComponentModel.Win32Exception”类型的异常出现在 system.windows.forms.dll 中其他信息:创建窗口句柄时出错。
      

  3.   

    TCustomListBox.Style
    --------------------------
    Determines whether the list box is standard or owner-draw and whether it is virtual.type TListBoxStyle = (lbStandard, lbOwnerDrawFixed, lbOwnerDrawVariable, lbVirtual, lbVirtualOwnerDraw);
    property Style: TListBoxStyle;DescriptionUse Style to specify whether the list box is a standard list box that displays text strings, or an owner-draw list box that can display graphical images. Owner-draw list boxes let you display items in some nonstandard way. In this case, you must write the code to paint items in the list box. In addition, Style controls whether the list box is virtual, which means that items are supplied dynamically using event handlers. By default, Style is lbStandard, meaning that the list box is not virtual and it displays each item as a string.
    ---------------------------
    lbVirtual The list box is virtual, but all items are strings with the same height. You must indicate the number of items in the list box by setting the Count property. You must supply the items in the list box using an OnData event handler. If the items have associated objects, you must supply them using an OnDataObject event handler. In addition, you must supply an OnDataFind event handler to provide the mapping from the strings in the list box to their indexes.可见,TCheckListBox可以实现你所说的功能。将style设为lbVirtual,然后分别在OnDataObject、OnData、OnDataFind里写相应代码。这些列表项目不是直接添加到列表里去的,而是在需要显示的时候指定数据。这个速度很快的,可以处理数据量很大的情况。
      

  4.   

    创建9百9十9万9千9百9十9个(9999999)个CheckBox控件,让用户去点中其中的某些,你想废掉用户的眼睛吧!
      

  5.   

    仅仅是理论代码
    var
     MyCheckBoxs:array of TCheckBox; //全局变量........
    ........procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    setlength(MyCheckBoxs,9999999);
    for i:=low(MyCheckBoxs) to high(MyCheckBoxs) do begin
     MyCheckBoxs[i]:=TCheckBox.Create(Self);
     MyCheckBoxs[i].Parent:=Self;
     MyCheckBoxs[i].Caption:=Inttostr(i);
     MyCheckBoxs[i].Left:=5;
     MyCheckBoxs[i].Width:=30;
     MyCheckBoxs[i].Top:=15*i;
     MyCheckBoxs[i].Visible:=true;
    end;
    showmessage('ok')
    end;
      

  6.   

    哈哈-------------------------------------------------------
    本回复由大傻的破玩意儿【CSDN's forum Explorer】完成!
    软件功能强大,速度超快!!支持中...
    软件下载地址:http://CoolSlob.ys168.com
      

  7.   

    facedge(朝戈)兄弟能详细说一下吗?
    这几个OnDataObject、OnData、OnDataFind事件怎么用!
    我看了帮助没有看明白
      

  8.   

    纳闷呢
    还有批发CheckBox控件的
    好家伙
      

  9.   

    facedge所说似乎不能解决该问题,并不节省内存
      

  10.   

    这还不好弄,画99999999999999999999999999999999个checkbox控件在A4得纸上,基本上就是点那么多个点点就可以了,然后程序中点击开始按钮后,showmessage('请把那张纸贴在屏幕上');
      

  11.   

    我说的方法是可行的,而且据我分析,这个方法应该是最理想的方法。因为它避开了直接创建Item,而是使用虚拟的。如果说这个方法依然有内存局限,那么这么多的项目当然要费内存了。9999999个元素的boolean(或别的类型)数组是很小的数据了吧,要不就是用数据库。
      

  12.   

    要知道TCheckBox派生于TWndComponent,所以每创建一个实例都要向系统注册一个Handle,而Windows管理每个Form的Handle是由限制的,在Win9x下是256个,在NT系统中要好些。不过那么多的窗口系统会给你一个提示Memory Out!!