Inserting textbox values in table
Hi!!!
I am making a window application in which there is a textbox in which we have to enter only numeric values...
How can I display a table on the form which has columns - ones,tens,hundred ,thousand,ten thousand,lakh , ten lakh etc. Now whatever number we enter in textbox that number should automatically get filled in this numeration table ....
For example , number entered is 2589,then in table 9 should be in ones column , 8 in tens, 5 in hundreds, 2 in thousands column................
How can I do this.....
Re: Inserting textbox values in table
You will use a GridView control to display the table. A simple logic to do this would be to convert the number into a string and then use SubString() method to get the ones, tens, hundreds, etc.
Re: Inserting textbox values in table
There is no database connectivity..........
Simply a number is entered in textbox and I want that number to be displayed in table
Re: Inserting textbox values in table
yes it is not necessary to use GridView for this problem.
i wrote this code for you:
Code:
private void button1_Click(object sender, EventArgs e)
{
string number = textBox1.Text;
char[] digits = number.ToCharArray();
int pos = 0;
foreach (char d in digits)
{
Control cnt = tableLayoutPanel1.GetControlFromPosition(pos,1);
Label lbl = (Label)cnt;
lbl.Text = d.ToString();
pos++;
}
}
to get the code work please add TableLayoutPanel to your form with 2 rows and 4 columns (first row canbe used as header for titles) then put lables in every cells and change the name of the lables in the first row to the tiles you want like (1s,10s,100s etc.)
Re: Inserting textbox values in table
Quote:
Originally Posted by
vinnijain
There is no database connectivity..........
Simply a number is entered in textbox and I want that number to be displayed in table
GridView does not mean that you have to have a database connectivity. You can use GridView for anything where a table can be used.