When i enter 12 in textbox it should convert into 0101010112
randomaly when i enter 134 it should convert into 0101010134
in windows form
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 9, 2014, 8:57 PM EDT
hi,
I think 01010101 is prefix right?
so in this case you can write textbox lost focus event and in this event you can add this prefix
textbox1.Text = "01010101" + textbox1.Text;
hope this will help you.
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 9, 2014, 9:50 PM EDT
Angel Princess100 reputationPosted Apr 10, 2014, 12:26 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 10, 2014, 12:30 AM EDT
Is it true what ever Munesh says?
so can you please provide more information? what is logic etc...
VulpesRank #55 · 29.2K reputationPosted Apr 10, 2014, 2:04 AM EDT
int len = textBox1.Text.Length;
if (len < 10)
{
string padding = "0101010101";
textBox1.Text = padding.Substring(0, 10 - len) + textBox1.Text;
}
Angel Princess100 reputationPosted Apr 10, 2014, 2:39 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 10, 2014, 2:44 AM EDT
I have test vulpes code it working fine for me....
What error are you getting? can you please share error text?
Angel Princess100 reputationPosted Apr 10, 2014, 3:09 AM EDT
Angel Princess100 reputationPosted Apr 10, 2014, 3:09 AM EDT
the error was
VulpesRank #55 · 29.2K reputationPosted Apr 10, 2014, 3:19 AM EDT
Anyway, glad it's working now :)