C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Searching a non-PrimaryKey column within a DataTable with a partial st Posted by KCI on 1 Oct 2009 at 9:48 AM
Hello all,

How can I allow a user to type a letter on the keyboard and have a DataGridView (DGV) change current row to the first occurrence of the letter within a non-Primary Key column.

For example, LastName is a column in a DGV. Typing ā€˜S’ should change the current row of the DGV to the first Lastname that starts with an ā€˜S’. Note: LastName is not the primary key of the bound table.

I am using a DataGridView bound to a DataSet.Table[] without a binding source.

Here is a code snippet I tried, but it returns -1:
ds.Tables["Students"].DefaultView.Sort = "LastName";
int intRow = ds.Tables["Students"].DefaultView.Find("S%");

I have also tried this, but it returns zero rows:
ds.Tables["Students"].DefaultView.Sort = "LastName";
DataRowView[] drv = ds.Tables["Students"].DefaultView.FindRows("LastName LIKE 'S'");

Thanks in advance,
KCI
Report
Re: Searching a non-PrimaryKey column Posted by s_pedro on 1 Oct 2009 at 9:59 AM
hi,
do you know how to program in java?

cus i need help in an urgent homework.....

could u plz see my question?

thanks

-"what goes around, comes around"
Report
Re: Searching a non-PrimaryKey column Posted by KCI on 2 Oct 2009 at 4:43 AM
Hello Pedro

Yes, I know Java. I learned it taking a class just like you. I would suggest you learn the basics and not ask someone to do your homework for you. I'm sure your teacher would be disappointed to hear you are soliciting help from random people on the internet.

Regards,
KCI




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.