Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Appending spaces onto TextBox current data until max length reached

$
0
0

Hi,

Very nearly reaching the end of my project and it's seemingly small things getting in my way! I have a DataGridView of which one column's string of 64 chars (containing a telephone number and email address) is broken down into two textboxes (MaintCompanyTel which gets the first 11 chars and MaintCompanyEmail which gets the other 53) on the loading of the Form. 

I can update the two broken down strings and rewrite the updated values once I "combine" the two values again and update the DGV. However, if the value in MaintCompanyTel or MaintCompanyEmail is shorter than the 11 or 53 characters (totalling 64 chars), then the values are not loaded once the form is re-opened later on. But the values are returned if I fill the textboxes with spaces until I hit the max limit of 11/53 chars set by myself.

Is there a way for me to automatically add spaces onto the end of the textboxes until the maximum limit for that textbox is reached, as opposed to doing it manually?

Here is my code for splitting the string into a CharArray:

 ' Declare the string to count
        Dim splittelandemail As String = Panel_SettingsDataGridView.Rows(5).Cells(2).Value.ToString
        ' Split the string into separate 
        Dim splittelemail As Array = splittelandemail.ToCharArray()
        'Show each digit in a popup
        For i = 0 To splittelemail.Length - 1
        Next

        MaintCompanyTel.Text = splittelemail(0) & splittelemail(1) & splittelemail(2) & splittelemail(3) & splittelemail(4) & splittelemail(5) & splittelemail(6) & splittelemail(7) & splittelemail(8) & splittelemail(9) & splittelemail(10)
        MaintCompanyEmail.Text = splittelemail(11) & splittelemail(12) & splittelemail(13) & splittelemail(14) & splittelemail(15) & splittelemail(16) & splittelemail(17) & splittelemail(18) & splittelemail(19) & splittelemail(20) & splittelemail(21) & splittelemail(22) & splittelemail(23) & splittelemail(24) & splittelemail(25) & splittelemail(26) & splittelemail(27) & splittelemail(28) & splittelemail(29) & splittelemail(30) & splittelemail(31) & splittelemail(32) & splittelemail(33) & splittelemail(34) & splittelemail(35) & splittelemail(36) & splittelemail(37) & splittelemail(38) & splittelemail(39) & splittelemail(40) & splittelemail(41) & splittelemail(42) & splittelemail(43) & splittelemail(44) & splittelemail(45) & splittelemail(46) & splittelemail(47) & splittelemail(48) & splittelemail(49) & splittelemail(50) & splittelemail(51) & splittelemail(52) & splittelemail(53) & splittelemail(54) & splittelemail(55) & splittelemail(56) & splittelemail(57) & splittelemail(58) & splittelemail(59) & splittelemail(60) & splittelemail(61) & splittelemail(62) & splittelemail(63)

And here is writing the combined value back to my DataGridView. 

Dim TelEmailjoinedstring As String
        TelEmailjoinedstring = MaintCompanyTel.Text & MaintCompanyEmail.Text
        TelEmailJoined.Text = TelEmailjoinedstring
        Panel_SettingsDataGridView(2, 5).Value = TelEmailJoined.Text 'write to DGV




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>