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 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

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

""If everyone is thinking alike, someone isn't thinking.""
- General George Patton Jr