473,895 Members | 3,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB2005 - Sort DataGridView on Text (FormattedValue ) of a ComboBoxcolumn instead of underlying value?

I have been searching all over the web for a way to sort a DataGridView based on
the actual text being shown in a ComboBox column as opposed to the underlying
value (an ID in this case). Can anyone tell me if this is even possible, and if
so, how to do it? If this is completely impossible, how would you suggest going
about sorting a ComboBox wherein the text displayed in the column is the
client's name, and the underlying value is an ID?

Thanks,
Matt
Jun 17 '06 #1
4 8653
Matt,

I do probably not understand your question, but to sort a datagridview is
typical used a dataview.
The property of that is a text(string) property.

http://msdn2.microsoft.com/en-us/lib...view.sort.aspx

Is that what you need?

Cor

"Matt" <br**********@c ommunity.nospam > schreef in bericht
news:em******** ******@TK2MSFTN GP02.phx.gbl...
I have been searching all over the web for a way to sort a DataGridView
based on the actual text being shown in a ComboBox column as opposed to the
underlying value (an ID in this case). Can anyone tell me if this is even
possible, and if so, how to do it? If this is completely impossible, how
would you suggest going about sorting a ComboBox wherein the text displayed
in the column is the client's name, and the underlying value is an ID?

Thanks,
Matt

Jun 17 '06 #2
Cor,

Unfortunately, this does not solve my problem, since it still leaves me unable
to sort by the actual text being displayed in the field, since that text is not
a part of the base DataTable object (it is being referenced in through another
DataSource on the ComboBox Column). What I need is a way to sort on what's
*actually showing* in the ComboBox Column, as opposed to any data that underlies
it. Is this possible?

Thanks,
Matt

Cor Ligthert [MVP] wrote:
Matt,

I do probably not understand your question, but to sort a datagridview is
typical used a dataview.
The property of that is a text(string) property.

http://msdn2.microsoft.com/en-us/lib...view.sort.aspx

Is that what you need?

Cor

"Matt" <br**********@c ommunity.nospam > schreef in bericht
news:em******** ******@TK2MSFTN GP02.phx.gbl...
I have been searching all over the web for a way to sort a DataGridView
based on the actual text being shown in a ComboBox column as opposed to the
underlying value (an ID in this case). Can anyone tell me if this is even
possible, and if so, how to do it? If this is completely impossible, how
would you suggest going about sorting a ComboBox wherein the text displayed
in the column is the client's name, and the underlying value is an ID?

Thanks,
Matt


Jun 17 '06 #3
Matt,

In my idea is the column that is related to the combobox always a column in
an underlaying table. The combobox is only used to fill it with values.

Why can you not sort on that using the dataview, did you try it already?

Be aware that the sort never standard is working while updating a row in a
datagrid(view).

I hope this helps,

Cor
"Matt" <br**********@c ommunity.nospam > schreef in bericht
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
Cor,

Unfortunately, this does not solve my problem, since it still leaves me
unable to sort by the actual text being displayed in the field, since that
text is not a part of the base DataTable object (it is being referenced in
through another DataSource on the ComboBox Column). What I need is a way
to sort on what's *actually showing* in the ComboBox Column, as opposed to
any data that underlies it. Is this possible?

Thanks,
Matt

Cor Ligthert [MVP] wrote:
Matt,

I do probably not understand your question, but to sort a datagridview is
typical used a dataview.
The property of that is a text(string) property.

http://msdn2.microsoft.com/en-us/lib...view.sort.aspx

Is that what you need?

Cor

"Matt" <br**********@c ommunity.nospam > schreef in bericht
news:em******** ******@TK2MSFTN GP02.phx.gbl...
I have been searching all over the web for a way to sort a DataGridView
based on the actual text being shown in a ComboBox column as opposed to
the underlying value (an ID in this case). Can anyone tell me if this is
even possible, and if so, how to do it? If this is completely
impossible, how would you suggest going about sorting a ComboBox wherein
the text displayed in the column is the client's name, and the
underlying value is an ID?

Thanks,
Matt


Jun 18 '06 #4
Hi Matt,

Thank you for posting.

If you have a DataGridViewCom boBoxColumn in your DataGridView, you have to
set the DataSource of the DataGridView to populate data in it. That's to
say, you must bind the DataGridView to a datasource.

If you set the SortMode of the DataGridViewCom oboBoxColumn to Automatic,
you can sort this column by clicking it. The sorting is based on the cells'
value in the column, not the FormattedValue. If you want to sort this
column based on the FormattedValue, it seems that you have to customize the
sorting.

There're several options for custom sort of DataGridView. These options are
listed below.
1. Calling DataGridView.So rt(DataGridView Column,ListSort Direction) method
2. Handling with the DataGridView's SortCompare event
3. Calling DataGridView.So rt(IComparer) method

You can refer to the below link for more information on the above three
options:
http://msdn2.microsoft.com/en-us/lib...08(d=ide).aspx

4. Using DataView and set the its Sort property

You can refer to he below link for more information on the option4:
http://msdn2.microsoft.com/en-us/lib...sort(d=ide).as
px

It seems that only option2 and option3 could be applied to sort the
DataGridViewCom boBoxColumn based on the FormattedValue. However, these two
options only apply under the condition that the DataGridView is NOT bounded
to a DataSource.

So in my opinion, it is impossible to sort a DataGridViewCom boBoxColumn
based on the FormattedValue.

If you have other concerns, please don't hesitate to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =======
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=============== =============== =============== =======

Jun 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2829
by: Fred Phase | last post by:
The following button definition works fine in Mozilla where the value "in" is assigned to "awol_status". In Internet Explorer 6.0.2800.1106 on Win 2K the value "switch status" is assigned to "awol_status". This is not what I want :-( <button type="submit" name="awol_status" value="in">switch status</button> I have searched Google for this issue and I read of this being a problem in IE 4 but in IE5 the value="" attribute would be used
2
13964
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the function, but doesn't work. I'm new to this - previous JavaScript experience mostly copy & paste - could somebody please point to where I'm going wrong. ~~~~~~~~~~~~~~~~~~~~~~~~~ <head>
2
16160
by: Bill nguyen | last post by:
I need help to set selected value of combobox column in DGV. I went this far then got stuck on what to do next:. How do I set "selected Value" of comboboxpayCode to value of column PayCode ? That is earningCode = payCode. I can't find .selectedValue in DatagridView ComboboxColumn . Thanks Bill
3
11955
by: joey.powell | last post by:
I have a datagridview where I set its "DataSource" property to a DataSet and its "DataMember" property to a table within the DataSet. I need for the DataGridView to "sort" through the contents of the DataSet as it binds. Can I specify a column on the DataSet that, sorted, will control the order of the rows in the datagridview? It seems to just parse over the data in the DataSet and bind to it, without my being able to control the order...
2
1715
maxamis4
by: maxamis4 | last post by:
I have a text box that holds a value of 300 how do I make it show $ 300.00, not to mention their are multiple records that have 1200, 900, and I want them to display with the dollar sign.
2
29669
by: tee | last post by:
Hi, How do i sort datagridview programmically, current i have the following code but i keep get the error saying "DataGridView control must be bound to an IBindingList object to be sorted.", What is IBindingList and how would i go about using it. Here are my code private void dataGridView1_ColumnHeaderMouseClick(object sender,
5
2639
by: usa51 | last post by:
Hi, I have a dropdown options value from 2 to 5. After I change the selection, in the same asp page, I also have a button "Add", how do I dynamically add 3 text fields if I select value 3 and then click "Add" button? Thanks!
3
4216
by: Frederik | last post by:
Hi group, I have a DataGridView that is mainly consisting of data bound columns. One column however is unbound. I'm not able to sort the grid on this column! Is that normal behaviour? If so, what are my options? Thanks (again) for your time, Frederik
3
1344
by: frenzy99 | last post by:
Can some one help me with this problem. I want to sort DataGridView based on the order in which values were added, not on the basis of any particular column, unlike the functionality provided by DataGridView.Sort()
0
9988
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10469
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9648
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8025
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4282
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.