display textbox shape value - vba

When you add a textbox shape to the screen, you can use one of the following two methods to edit the displayed string:
[textbox].textframe.characters.text
or
[textbox].textframe.characters.caption
Is there any benefit of using one over the other? Any limitations?

Related

How to find out which field a text box is linked to on a form? (Opposite direction of the ControlSource Property)

I have a form with multiple text boxes and want to select the one that is linked to a specific field in my dataset.
What I'm trying to do is basically the opposite direction of the ControlSource property... I know the field and want to find the associated text box.
E.g.: My dataset consists of the fields : Height, hair colour, weight, shoe size.
I have a form equipped with text boxes (for data entry) for each and every one of those fields.
I now want to select the text box linked to the field "weight"....
I could cycle through the controls on the form without a question, but is there a property of the text box telling me which field it's currently linked to?
I think I'm just too dumb to google it, but I just can't seem to find anything of the sort...
Thanks for your help in advance!
I could cycle through the controls on the form without a question, but
is there a property of the text box telling me which field it's
currently linked to?
Yes, that is - as you mention - property ControlSource …
So, loop the controls collection of the form (filter on control type TextBox) and find that (or those as it could be) bound to your field.

Is their any CharacterUpDown Control in vb.net

In VB Win-forms Application a NumericUpDown Control is used for only to scroll numbers. Its definition is:
The Windows Forms NumericUpDown control looks like a combination of a text box and a pair of arrows that the user can click to adjust a value. The control displays and sets a single numeric value from a list of choices. As Shown here.
I want to use strings instead of numeric values. For example, Grades: "A","B","C", etc. I think I will need to use UserContorl to code another custom "StringUpDown" Control.
You can't add String values to Numeric Drop down. instead for this you can use DomainUpDown here is the code to place a DomainUpDown in your form that contains A - Z characters
Dim domainUpDown1 As DomainUpDown
domainUpDown1 = New System.Windows.Forms.DomainUpDown()
For i As Integer = 65 To 90
domainUpDown1.Items.Add(Chr(i))
Next
Controls.Add(domainUpDown1)
Note : This control is available in Tool box also
You can change values using the ByRef=""
e.g. RefValues="Red;Blue;Green;Brown"
Hope this is what you were looking for
Link: mindStick

Show Data Grid View specified cell value in Textbox

I am a student programmer who is learning VB. I am trying to make a telephone book type project in VB (Windows Forms). In my project I am using an unbound Data Grid View control. Below the Data Grid View, I have some textboxes which will display the values of the selected row. On the form load event, my program accesses a file and populates the Data Grid View control with values from the file. This works perfectly, but the problem I get is when I use the code:
txtLast.Text = dgvMain.Rows.Item(0).Cells(0).Value
to populate the textbox called txtLast with the value at the specified cell, the textbox doesn't display the value. The program doesn't crash or hang, it simply won't display the value and when I try to edit the textbox, it acts as if the textbox is empty. I have tried using
txtLast.Text = dgvMain.Rows.Item(0).Cells(0).Value.ToString()
as well as trying to refresh my Data Grid View control and the textbox. Nothing has worked so far. When I use a breakpoint to see whether that line of code is executed, the autos window shows me that the line of code is executed and that it sees the value of the specified cell as "Smith". However, when I press F11 to step into the next line, the textbox.text property remains as "" instead of changing to "Smith".
Note: when I manually specify the text through the code (i.e. txtLast.Text = "Test") it will show that text. Also, this problem is not with just one textbox, it is with every textbox that I use (I have 5 textboxes showing various values from the specified row). The weird thing is that out of the 5 textboxes, one of them, the masked textbox which shows the phone number works perfectly with the same line of code. (note it is not a problem only affecting regular textboxes as I have tried using both regular textboxes and masked textboxes, both produce the same problem except for the phone textbox).
Also, I would prefer to keep the Data grid view unbound (not connected to a database) and the textboxes unbound (not connected to the data grid view as a data source) because while browsing the internet I have seen people suggesting to bind the textbox or data grid view, however I do not understand how to do so, and I believe that this can be done without binding to a data source.
Any help is appreciated in trying to figure out why the text doesn't change. Let me know if you need any other info or if part of my explanation is unclear.
Thanks!

is it possible to anchor a control to another control?

Is it possible to anchor a control to another control?
Lets say i want my Button1 to keep its 4px distance from Textbox1 control without
using FlowLayoutTable control?
"Why would be this advantageous?" - one could ask
Well let's say you have a SplitContainer with a vertical splitter and you have Textboxes
in SplitContainer.Panel1 which are anchored to the left and right but their maximum size's
width is smaller than you allow to the SplitContainer.Panel1's width to have (maybe
because you want text to show up there or because additional padding or whatever,you name it)
Now let's say you also have a button next to Textbox1 and you dont want Textbox1 to be
overlapped by the Button1 because its extends to far.
If i want to have my textbox fill the SplitContainer.Panel1 in a fashion that it leaves space for
Button1 control while still both of them are anchored to the right how would i do it?
I extensively use TableLayoutPanels and FlowLayoutPanels to accomplish this. For you specific circumstance I would use a TableLayoutPanel with three columns and a row for each TextBox.
Column 1: Auto-width, contains Labels all with AutoSize = True.
Column 2: 100% width, contains TextBoxes all with Anchor = Left, Right.
Column 3: Auto-width, contains the Button in the appropriate row.
Next, I set all text boxes, except for the one next to the button, ColumnSpan = 2. Then just put the TableLayoutPanel in the SplitPanel and set Dock = Fill.
it will be a sequence in live which should be flow out from left and keep working lets the right side should be layout.
List item safty cares should be provided.
List item all things that use in this method should be provided and be check;

How would you make the text in a checkbox cell be able to be edited?

How would you make the text in a check box cell able to be edited like in a text cell instead of it just checking the Checkbox? The thing is that the Checkbox is Boolean in the Core Data Model and the Text is a String, so I don't know how I would make this work.
Have two columns: One with a checkbox cell and the other with a text cell, each bound to the appropriate property of your model objects.
Why use checkbox? The checkbox is designed to have two values only as you say. Therefore, you can try other controls, such as input area and so on. What I mean is that you can't make the rectangle to roll because it can't roll at all, right?