GenericEditingControlShowing

by ssi 8. November 2013 07:41

  

Edit Text box for datagridview

private void GenericEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)

        {

            int colIndex;

            int rowIndex;

            var txtBox = e.Control as TextBox;

            colIndex = tbl_ssi_GLTransactionDataGridView.CurrentCell.ColumnIndex;

            rowIndex = tbl_ssi_GLTransactionDataGridView.CurrentCell.RowIndex;

            if (e.Control is TextBox)

            {

                if (txtBox != null)

                {

                    DataClasses1DataContext dc = new DataClasses1DataContext(glo.ConnectionString);

                    txtBox.CharacterCasing = CharacterCasing.Upper;

                    txtBox.TextChanged += new EventHandler(ItemTxtBox_TextChanged);

                    txtBox.MaxLength = aMaxFieldLength[colIndex];

                    switch (colIndex)

                    {

                        case pCOL_BRANCHNUMBER:

                            txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

                            txtBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

                            var qry = dc.tbl_employee_cost_ctrs.Select(r => new { r.Cost_Center });

                            foreach (var rc in qry)

                                txtBox.AutoCompleteCustomSource.Add(rc.Cost_Center.ToString());

                            break;

                        case pCOL_GL_ACCOUNTNUMBER:

                            txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

                            txtBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

 

                            var qryACCT = dc.tbl_ssi_MVFees.Select(r => new { r.GL_AccountNumber  });

                            foreach (var rc in qryACCT)

                                txtBox.AutoCompleteCustomSource.Add(rc.GL_AccountNumber.ToString());

                            break;

                        default:

                            break;

                    }

 

                }

            }

        }

Tags:

Add comment

biuquote
  • Comment
  • Preview
Loading

Calendar

<<  May 2026  >>
MoTuWeThFrSaSu
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"Fill the unforgiving minute with sixty seconds worth of distance run."
Rudyard Kipling