ListBox排序记录 - 不使用命令按钮 [英] ListBox Sort Records - With out using Command Buttons

查看:62
本文介绍了ListBox排序记录 - 不使用命令按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想知道是否可以使用列表框的第一行来禁止使用字段名称(产品名称,单价...等)来运行一个on click事件,在这种情况下更改列表框的sql Order By。 - 我已经看到一些使用命令按钮的例子,它们可以正常工作,但不像我希望的那样整洁。

Hi,

I was wondering if it was possible to use the first line of a listbox which contrains the field names (Product Name, Unit Price ... etc) to run an on click event to change the sql of the list box in this case Order By. - I have seen some examples using command buttons which will work, just not as neatly as i was hoping for.

推荐答案

答案可能是肯定的,但......

其他列中的排序顺序怎么样?假设您想要按价格下降排序。假设您也有相同价格的产品。我认为你会希望按字母顺序保留这些产品名称。


我通常希望列表框的行源最终会像
The answer is probably yes, but...
What about the sort order in the other columns. Suppose you want to sort on price descending. suppose you also have a number of products all at the same price. I presume you would want to keep the those product names in alphabetical order.

I would normally expect a list box''s row source to end up with something like
展开 | 选择 | Wrap | 行号


我过去一直在考虑这样做,并且使用Access''内置的ComboBox没有附加事件单击列标题。


我想出的最佳解决方案是添加额外的ComboBox,它会重新排序ComboBox。


......有一些合作从第三方控件制造商那里进行控制,但是我不建议这样做,因为它会使数据库复杂化,因为部署变得棘手并且通常会产生与第三方控件相关的成本。



此代码是Two Combobox方法的实现,其中cboPipSort确定其他四个组合框的排序顺序。
I''ve looked into doing this in the past and with Access'' built-in ComboBox there isn''t an Event attached to clicking on a Column Header.

The best solution that I came up with was to add additional ComboBox that would reorder the ComboBox.

...There are some controls out there from third-party controls manufacturers that do this, but I wouldn''t recommend going this route as it will complicate your database considerably as deployment gets tricky and there is often a cost associated with third-party controls.


This code is an implementation of the Two Combobox approach where cboPipSort determines the sort order of four other comboboxes.
展开 | 选择 | Wrap | 行号


是的,我知道没有与列标题相关的事件,但我是使用MouseUp猜测一些相当复杂的东西?向下我可能能够相对于列表框角落,已选择哪一列。

在我知道OP想要对所有列进行排序之前,我还没有准备好看这个。


我怀疑你的那种方法将提供令人满意的答案,但找到哪个列标题已被按下将是一个有趣的练习。


Phil
Yes, I know there isn''t an event connected with a column header, but I was guessing that with some pretty complicated stuff using MouseUp ? Down I might be able to work out relative to the list box corner, which column had been selected.
I wasn''t prepared to look at that until I knew how the OP wanted to sort all the columns.

I suspect that your sort of approach is going to provide the satisfactory answer, but finding which column header had been pressed would be an interesting exercise.

Phil


这篇关于ListBox排序记录 - 不使用命令按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆