Click here to Skip to main content
15,908,111 members
Home / Discussions / C#
   

C#

 
QuestionRe: Searching a non-PrimaryKey column within a DataTable with a partial string. Pin
KCI-VA1-Oct-09 10:37
KCI-VA1-Oct-09 10:37 
AnswerRe: Searching a non-PrimaryKey column within a DataTable with a partial string. Pin
KCI-VA8-Oct-09 5:32
KCI-VA8-Oct-09 5:32 
Here is how I eventuall worked this out. I have not tested it deeply so take this only as an outline:

using System.Collections.Generic;

private string strKeyPreview = String.Empty   // Modular level
private List<string> strStudent_List = null;  // Modular level

private void dgv_KeyPress(object sender, KeyPressEventArgs e)
{
   strKeyPreview = e.KeyChar.ToString();
   int intRow = strStudent_List.FindIndex(StartsWithLetter);
   if (intRow >= 0)  // Will be -1 if not found
   {
      // Set cell rather than row.
      dgv[3, intRow].Selected = true;  // Use the index of the displayed name
      dgv.FirstDisplayedScrollingRowIndex = intRow;
   }
}

private bool StartsWithLetter(String s)
{
   if (s.StartsWith(strKeyPreview.ToUpper()) == true)
   {
      return true;
   }
   else
   {
      return false;
   }
}


// The following code should be just after you create the datasource for your dgv.
// Maybe there is better way than brute force ... help me out here.
strStudent_List = new List<string>();
foreach (DataRow dr in dt.Rows)  // Where dt is the DataTable bound to the dgv
{
   strStudent_List.Add(dr[2].ToString());  // Use the index of the displayed name
}


Feel free to post improvement ... I'm sure this is not bullet proof as it is untested.

Live long and prosper.

QuestionWindows Forms: TreeView in SplitContainer flickers on Resizing the screen ar runtime Pin
Poornima Naik1-Oct-09 3:21
Poornima Naik1-Oct-09 3:21 
QuestionRemove program from Control panel using C# Pin
Ajithevn1-Oct-09 3:07
Ajithevn1-Oct-09 3:07 
AnswerRe: Remove program from Control panel using C# Pin
stancrm1-Oct-09 3:18
stancrm1-Oct-09 3:18 
QuestionRe: Remove program from Control panel using C# Pin
Eddy Vluggen1-Oct-09 3:48
professionalEddy Vluggen1-Oct-09 3:48 
AnswerRe: Remove program from Control panel using C# Pin
Ajithevn1-Oct-09 6:07
Ajithevn1-Oct-09 6:07 
GeneralRe: Remove program from Control panel using C# Pin
Eddy Vluggen1-Oct-09 10:07
professionalEddy Vluggen1-Oct-09 10:07 
QuestionBuild issue [modified] : SOLVED Pin
Mustafa Ismail Mustafa1-Oct-09 2:54
Mustafa Ismail Mustafa1-Oct-09 2:54 
AnswerRe: Build issue Pin
Vasudevan Deepak Kumar1-Oct-09 3:01
Vasudevan Deepak Kumar1-Oct-09 3:01 
GeneralRe: Build issue Pin
Mustafa Ismail Mustafa1-Oct-09 3:52
Mustafa Ismail Mustafa1-Oct-09 3:52 
AnswerRe: Build issue Pin
Keith Barrow1-Oct-09 3:05
professionalKeith Barrow1-Oct-09 3:05 
GeneralRe: Build issue Pin
Mustafa Ismail Mustafa1-Oct-09 4:04
Mustafa Ismail Mustafa1-Oct-09 4:04 
QuestionMS Office Outllok - VSTO - Host Windows.Forms control within an Outlook 2003 form region Pin
Programm3r1-Oct-09 2:13
Programm3r1-Oct-09 2:13 
AnswerRe: MS Office Outllok - VSTO - Host Windows.Forms control within an Outlook 2003 form region Pin
Richard MacCutchan1-Oct-09 2:23
mveRichard MacCutchan1-Oct-09 2:23 
QuestionRe: MS Office Outllok - VSTO - Host Windows.Forms control within an Outlook 2003 form region Pin
Programm3r1-Oct-09 2:31
Programm3r1-Oct-09 2:31 
QuestionHost Windows.Forms control within an Outlook 2003 form region using VS2008 Pin
Programm3r1-Oct-09 2:54
Programm3r1-Oct-09 2:54 
AnswerRe: Host Windows.Forms control within an Outlook 2003 form region using VS2008 Pin
Programm3r1-Oct-09 3:15
Programm3r1-Oct-09 3:15 
AnswerRe: Host Windows.Forms control within an Outlook 2003 form region using VS2008 Pin
Programm3r1-Oct-09 3:26
Programm3r1-Oct-09 3:26 
QuestionFeedback Mechanisms Pin
satsumatable1-Oct-09 1:36
satsumatable1-Oct-09 1:36 
AnswerRe: Feedback Mechanisms Pin
stancrm1-Oct-09 1:40
stancrm1-Oct-09 1:40 
QuestionC# vs Powershell in querying 64bit registry from 32bit system Pin
Randy Grugan1-Oct-09 1:36
Randy Grugan1-Oct-09 1:36 
QuestionGetting HTML Source from a WebPage in String-format, using NetworkCredentials [modified] Pin
Dimitri Backaert1-Oct-09 1:24
Dimitri Backaert1-Oct-09 1:24 
AnswerRe: Getting HTML Source from a WebPage in String-format, using NetworkCredentials Pin
Dimitri Backaert2-Oct-09 2:18
Dimitri Backaert2-Oct-09 2:18 
QuestionOptional Parameter Pin
ksss_maheshece1-Oct-09 1:23
ksss_maheshece1-Oct-09 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.