Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how do i add the textbox with automatic identify the sql data type when key in the data to textbox?TQ, because the code i do is, when the gridcontrol(devexpress component) is fill with data, panel5 will fill up the loop of textbox follow by the quantity of sql columns.



C#
/*load component programatically*/
        private void filltexttotextbox(DataTable DataT)
        {
            DevExpress.XtraEditors.TextEdit NTB;
            int y = 12;
            if (DataT != null)
            {
                foreach (DataColumn DC in DataT.Columns)
                {
                    NTB = DevTE(10, y);
                    NTB.DataBindings.Add(new Binding("Text", DataT, DC.ColumnName));
                    panel5.Controls.Add(NTB);
                    y += 23;
                }
            }
            else 
            {
                return;
            }
        }
        
        /*create textbox programmatically*/
        private DevExpress.XtraEditors.TextEdit DevTE(int X, int Y)
        {
            DevExpress.XtraEditors.TextEdit TE = new DevExpress.XtraEditors.TextEdit()
            {
                Text = null,
                Location = new Point(X, Y),
                Size = new Size(150, 50),
            };
            return TE;
        }

//load data to gridcontrol control
        private void loaddata()
        {
            gridControl1.DataSource = DT3;
            gridView1.OptionsBehavior.Editable = false;
            filltexttotextbox((DataTable)gridControl1.DataSource);
        }


What I have tried:

i have try to using datatable to add, but also not working, because the code that i want to do is, when the textbox key in value that no same with the sql data it will show a messagebox to notifier the value is no same with the data type.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900