Have a look at this example first,
click here. I want you to see only the example of how he changed a label into text box after he hits edit.I want to make edit profile page but I don't want to use bind grid view. Is there any possible ways to retrieve some data from table in database to be shown in labels then when uset hits the edit button, the label will change to textbox?
why do you need to show a label ?
you can show it in a text box and set IsReadOnly or ReadOnly to true, set style to flat and remove border(it'll appear like a label), and then on the Edit Action, you can change this ReadOnly/Editable property.
Related
I created a simple form in C# with only a textbox and a button.
The form contains a function to set the text in the textbox and another function that closes the form if the button is clicked.
Now I execute the form, set the text and display the form.
Everything is fine, but: The text in the textbox is "selected / marked".
What can I do that the text is not selected and the focus is on the button?
(button.focus is not working)
Thanks for help
You can manually set the selection after changing the content, for example like this:
this.textBox1.SelectionStart = this.textBox1.Text.Length;
Where textBox1 is the textbox you're working with. This clears the previous selection and makes a new one, effectively setting the cursor inside the textbox to the last element of it's content.
Alternatively, select the button instead of focussing it, like this:
this.button1.Select();
Where button1 is the button you want to select after changing the textbox' content.
Solution:
I changed the TabIndex from textbox from 0 to 1 and
have tabindex 0 to the button.
Then text is no longer marked.
I have a control, which has an autocomplete textbox. When I enter text into the textbox, I can successfully display the autocomplete dropdown, and auto-fill possible text. When I find the item I want, I select it, call my database and get the object, finally reloading the controls blank fields with the correct data.
The autocomplete textbox is also loaded with the data pulled from the last autocomplete call.
When I delete or try to type in the autocomplete box, it doesn't display any of the autocomplete dropdowns or auto-fill text.
Thanks in advance!
Set Auto complete mode to suggest append so that it will suggest one or more suggested completion strings it has.
TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
I have two textboxes and I want to display their value in a grid.
When I click on the Add button, I want to create a grid dynamically at runtime. I also want to add the textbox values into the grid repeatedly when I want to display it.
ok... As per what you have said you want to create a dynamic grid and and you would like to add Values inside the textbox control inside the gridview? is my understanding is correct ?
check this link out : http://praveensunsetpoint.wordpress.com/2008/05/09/dynamic-gridvieweditdeleteinsertselect-just-copy-paste-and-enjoy-it/
I have a ListView in details view so it has 2 columns - but with the text which populates the list, it is more important to see the end of the text instead of the beginning. Is there any way to set the listview to show the right-side of the text by default (ie have the ... at the beginning instead of the end if the text is too large to fit within the column)?
There is a RightToLeft property on most controls which setting to true will change the alignment.
How can I prevent bindingSource Current item from changing?
(there is no changing event with cancel argument...)
This is scenario:
I have a dataGridView, and text-boxes on the same form.
I am using text-boxes to change values in the datasource (with standard databinding)
Bindings are written manually (After save button is clicked)
When user selects another row using DataGridView, bindingSource.Current propery is changed, and text boxes are updated with values from selected row. Changes that user entered are lost.
Is there any way to prevent this problem?
Can I prevent bindingSource.Current property from changing?
Is there any better option to prevent this behaviour?
(disabling dataGridView is unfortinutelly not an option)
It sounds like you don't want to not change bindingSource.Current, but rather you want to save the contents of the text boxes before you change the current row? If you've bound a collection to the bindingSource, then don't the text boxes refer to properties in the current element in that collection?
I'm not really sure what you're trying to do, but a shot in the dark might be to bind the same DataSource to two different BindingSource objects, something like this:
gridBindingSource.DataSource = theDataSource;
textBoxBindingSource.DataSource = theDataSource;
myDataGrid.DataSource = gridBindingSource;
firstNameTextBox.Bindings.Add (new Binding ("Text", textBoxBindingSource, "FirstName"));
but this would be weird, because if theDataSource is appropriate for a grid control, then it's a collection of things that have a FirstName property. Maybe if you were more specific in your question.
ETA: If you want to save the text box contents to the current row, call ValidateChildren () on the container before the bindingSource.Current property changes.
I have a somewhat similar framework with both grid and textboxes on same form. When user clicks the EDIT button (or Add), I just disable the gridview control itself...
MyDataGrid.Enabled = false;
continue editing..
Then in the SAVE, if all is ok,
MyDataGrid.Enabled = true;