My goal: Place the value from sqlite database into the inputField as text. I want the user to be able to update the record/value of that database. Baically, I am trying to make a note app kinda like note on iPhone.
My issue: The text shows up in the field inside the text and contentfield, including the input cursor/caret. When the user clicks on the text field it resets everything to empty.
What I have tried: I created a script that will change the value of text inside the inputField to a value fetched from the database. The text gets updated as expected. Then as soon as I or other users press on the inputField the value dissapears, similar to how a placeholder works. However, I want the value to stay in place so the user can edit it.
the code:
TextMeshProUGUI contenttext =
input1.transform.Find("Text").GetComponentInChildren<TextMeshProUGUI>();
contenttext.text = source;
This is suppose to update the text component, which is a child of text area which is a child of contentfield. Here are before and after pictures of the inspector.
You need to set the value in the .text field of the TMP_InputField, not the TextMeshProUGUI
input1.transform.Find("Text").GetComponentInChildren<TMP_InputField>().text = source;
Related
I'm in the process of creating a front-end Windows Forms application, which will have multiple uses. One of those uses will be to allow the end-user to manage the contents of a database table.
At the moment, my form contains a DataGridView object which uses a DataTable as its source. That datatable is populated from a stored procedure which selects every row from the table based on criteria specified by the end user. I want to put code into the DataGridView which will look at the row that's been selected by the user, and will populate a series of text boxes with the details from that row.
I want to avoid hard-coding a text box for each column in the DataGridView, since it's highly possible that in the future I might add columns to the underlying stored procedure. Therefore, my plan is that the first time the user selects a row, the application would dynamically create a text box for each column, size that text box appropriately (both height and width) and add the appropriate labels.
So far, the code I've written creates a brand-new DataTable, and adds columns to store the following information about each column in the DataGridView:
The actual name of the DataGridView column;
The name that I wish to give to the associated label;
The text that I wish to assign to the associated label;
The top and left positions of the associated label;
The name that I wish to give to the associated text box;
The value that I wish to display in the associated text box;
So far when the user initially clicks on a row, everything is working well: the text boxes get created in a vertical column, with the associated label to the left of each text box and the appropriate value displayed in each one. Each text box has its width dynamically set based on the contents of that text box so that everything can easily be seen.
The difficulty comes when the user changes from one row of the DataGridView to another. The code that runs to create each control looks like this:
if (pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Remove(txtCurrent);
}
if (!pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Add(txtCurrent);
}
When the code first runs, all seems to be fine. However, if it gets fired a second time (at which point it should remove and re-create the control) it doesn't seem to detect the prior existence of the control and simply creates a second copy of it in the form.
For information, the form I'm building has multiple uses which are dictated by a series of buttons. Therefore, I'm creating the controls for this particular use inside a Panel (pnlManageJobManagerOutcomes). I'm completely stumped as to why the code doesn't spot the existence of those controls during subsequent executions.
TIA
I've figured out a way to do it, which may seem to be clunky but which seems to work.
Since it doesn't appear that I can check to see whether the Panel I'm working with Contains the field name, I've written a method which will loop through the controls in that Panel and return a count of the number of instances of that control in the Panel's Controls array. If the method returns a 0, this means the Control doesn't exist in that Panel and I can go ahead and create it.
I need to create a text box that the user can't change the value of.
Also I would like the text box to display the value of another combo box and update when that combo box's selected item changes
Please help me.
Click on the Text Box and in the Properties Tab change the value of ReadOnly to “True”
TextBox.ReadOnly = true; should do the trick
My dropdown box is of type "Input" and its values are listed using table.I'm able to get the rows using following code.
WebElement table = driver.findElement(By.id("testTable"));
List<WebElement>tr_collection=table.findElements(By.xpath("id('testTable')/tbody/tr"));
Row text is retrieved only when the dropdown is clicked and text is displayed.Is it possible to get the text when it is hidden ?
The method WebElement.GetText() returns the text visible to a user. To get the hidden text, you can read the HTMLElement.textContent property. Though, I would recommend it in a testing context since it doesn't reflect a real usage.
To get the text with .GetAttribute:
string text = element.GetAttribute("textContent");
To get the text with .ExecuteScript:
string text = (string)driver.ExecuteScript("return arguments[0].textContent;", element);
I have text box to fill the ph.numbers in that, here what i want is, whenever i'm entering the value in that text box i need to add another empty text box dynamically where i can add another value in that in the same way if they are entering any value into this new empty box another empty text box should add at the bottom of this. And after all there is a confirm link button. When clicking on it all these ph.numbers entering on the text boxes should get. How is it possible?
You add textboxes dynamically using jquery and on the button click/submit there values to the server. What you can do is on keyup event of a textbox you can add another below it.
Try this.
I'm basing this condition that your number format is of 11, Ex: 09123456789
So on the Textbox_Textchanged event of your textbox.
if(textbox.text.length >= 11)
{
Textbox text = new Textbox();
text.TextChanged += Textbox_Textchanged; // So it would also trigger the event
// Do positioning here
}
Im thinking you can better optimize this by having a better EventArgs but you get the idea right?
I have a method called void showdata() and If I do this...
textBox1.Text = ds.Tables[0].Rows[rno][0].ToString();
comboBox1.Text = ds.Tables[0].Rows[rno][1].ToString();
I am able to retrieve values from database but I am unable to retrieve value from radiobuttons e.g.
rBMale.Text = ds.Tables[0].Rows[rno][3].ToString();
by using navigation buttons.
When I say values I mean the green dot that you see from the application not the string value. I have named rBMale as radiobutton.
Does anyone know why that is?
Thanks
It is not clear, but it seems that you want to set the Checked property of the RadioButton.
rBMale.Checked = Convert.ToBoolean(ds.Tables[0].Rows[rno][3]);
This property is used to paint the RadioButton with the glyph to represent the value for true or for false
The Text property of radio buttons and check boxes is the on screen text that tells the user what the button is (in theory) and has little or nothing to do with its value. What you are probably looking for is the Checked property, which is a bool.
try something along these lines:
rBMale.Checked = Convert.ToBoolean(ds.Tables[0].Rows[rno][3]);