troubleshooting Question

How to get C# lookup window to land on first matching record

Avatar of rwheeler23
rwheeler23Flag for United States of America asked on
C#
5 Comments1 Solution15 ViewsLast Modified:
I have this method that correctly displays a list of batch numbers. I would like to refine it by passing down a batch prefix and have the display begin at whatever that prefix is. I want the user to still be able to go forward and backward in the list.The data resides in an MSSQL table.Is this something that can added or is it best to use some third-party developer tool?

        private void DisplayBatches()
        {

            DataTable dataTable = new DataTable();

            /* dataTable = new DataTable(); */

            string commandText = "SELECT BACHNUMB AS 'Batch ID'," +
                                        "CASE WHEN BCHSOURC = 'GL_Clearing' THEN 'Clearing Entry' " +
                                             "WHEN BCHSOURC = 'GL_Normal' THEN 'General Entry' " +
                                             "WHEN BCHSOURC = 'Invoice Entry' THEN 'Invoice Entry' " +
                                             "WHEN BCHSOURC = 'IV_Trans' THEN 'Transction Entry' " +
                                             "WHEN BCHSOURC = 'IV_Trxent' THEN 'Transfer Entry' " +
                                             "WHEN BCHSOURC = 'ASMENT' THEN 'Assembly Entry' " +
                                             "WHEN BCHSOURC = 'PM_Payment' THEN 'Manual Checks' " +
                                             "WHEN BCHSOURC = 'PM_Trxent' THEN 'Payables Trx Entry' " +
                                             "WHEN BCHSOURC = 'Rcvg Trx' THEN 'Receivings Trx Entry' " +
                                             "WHEN BCHSOURC = 'Rcvg Trx Ivc' THEN 'Purchasing Invoice Entry' " +
                                             "WHEN BCHSOURC = 'RM_Cash' THEN 'Cash Receipts' " +
                                             "WHEN BCHSOURC = 'RM_Sales' THEN 'Transaction Entry' " +
                                             "WHEN BCHSOURC = 'Sales Entry' THEN 'Sales Transaction Entry' " +
                                             "WHEN BCHSOURC = 'XPM_Cchecks' THEN 'Computer Checks' " +
                                             "ELSE 'Unknown' END AS 'Origin'" +
                                             ",CASE WHEN NUMOFTRX = 0 THEN 'No Transactions' " +
                                             "ELSE CONVERT(CHAR(5),NUMOFTRX) +' Transactions' END AS 'Status'" +
                                             ",CASE WHEN BACHFREQ = 1 THEN 'Single Use' " +
                                             "ELSE 'Unknown' END AS 'Frequency' " +
                                             "FROM[dbo].[SY00500] " +
                                             "WHERE SERIES = 3 AND BCHSOURC='Sales Entry' " +
                                             "ORDER BY BACHNUMB";

            int recordCount = DataAccess.ExecuteDataSet(ref dataTable, Controller.Instance.Model.GPCompanyDatabase, CommandType.Text,commandText,null);

            /* MessageBox.Show("Record count : " + recordCount.ToString() + " - " + commandText); */

            dgvBatches.ReadOnly = true;
            dgvBatches.RowHeadersVisible = false;
            dgvBatches.DataSource = dataTable;

            dgvBatches.Columns[0].Width = 120;
            dgvBatches.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvBatches.Columns[0].DefaultCellStyle.Format = "0";
            dgvBatches.Columns[0].HeaderText = "Batch ID";

            dgvBatches.Columns[1].Width = 140;
            dgvBatches.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvBatches.Columns[1].DefaultCellStyle.Format = "0";
            dgvBatches.Columns[1].HeaderText = "Origin";

            dgvBatches.Columns[2].Width = 120;
            dgvBatches.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvBatches.Columns[2].DefaultCellStyle.Format = "0";
            dgvBatches.Columns[2].HeaderText = "Status";

            dgvBatches.Columns[3].Width = 100;
            dgvBatches.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvBatches.Columns[3].DefaultCellStyle.Format = "0";
            dgvBatches.Columns[3].HeaderText = "Frequency";

            dgvBatches.EditMode = DataGridViewEditMode.EditOnEnter;
            dgvBatches.Focus();
        }
ASKER CERTIFIED SOLUTION
Kyle Abrahams
Director of Information Technology

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004