Winform - multi line Textbox changes scroll position on refresh - winforms

I have a winform application that has a textbox, multiline, readonly where I display a kind of log that is refreshed each second. The text box can have more than 100 lines of text.
On each refresh, if the user scroll and selection are lost.
I need a way to allow to the user to keep the scroll and selected text.
I tried to replace only the line that changes - didn't work (using Lines property)
I tried to save the selection before update and re-select it after - didn't work.
I tried to use RichTextBox instead - didn't work.
Anyone did something like this before? Is any library (custom control) I can use instead?
Thank you.

Related

Finding empty label in Windows form

I am new to Windows Form application and trying to build a small application.
I had dragged and dropped a label on the main form.
Then I deleted its text property to empty string basically hiding the label.
Now I would like to move this label to some other location on the form but unable to do so because I cannot find it.
I checked the designer file and its there.
But I cannot find it in the form so that I can grab it and move to a different location.
Please help.
Thanks
Use Document Outline. Look at the following images.
That happens to me several times, and a few weeks ago I found a way to get the empty label like this:
On the tab "Properties" just click on the arrow to show all controls and click on the label you want, this will automatically select the label on your form..

DevExpress DateEdit Force user to use menu popup

I have a WinForms app that uses this control and I would like to prevent the user from typing in a date. We want to make them have to use the popup calendar to make the date selection.
I tried setting ReadOnly of course but that puts the whole control into the read only state.
Our version of DevExpress is: 9.1.9.0
You can accomplish this task using the RepositoryItemButtonEdit.TextEditStyle property.
Assign the DisableTextEditorvalue with this property. In this mode a button editor is displayed in its normal way. However, editing and selecting text is not allowed.
Code snippet:
dateEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;

Trigger when application is not active

I have an application(Winform, TAB based MDI application), now we are adding few features. These Features are developed in WPF. A new form contains Element host, which will host this WPF User control. This newly added Form is displayed in every Tab's one corner. When application minimizes/Maximizes events are trigger, through these I am able to show or hide this new form. Also, this new form's Topmost Property is set true.
But when main form is still showing and when another application(like a note pad) is opened, the newly added form displayed over this notepad. The new form supposed to go behind the notepad, but it is always top.
Any suggestion on how to send it back.
Thank you,
Selected answer from
Detect when application becomes active post solved my problem.
I am also capturing
main.Deactivate += new EventHandler(main_Deactivate);
Thank you.

In my Windows Phone app,I want to turn my current page unable in gray and show a textbox in foreground

Like the title said,how may i turn the grid(or page) and the components in it into background gray and unable and show a new component in foreground.
It's a common effect in the web page,but i cannot do that with a xaml.
Please answer in detail better with sample code if you do.Thanks in advance.
Here's an example of using a Popup to display a UserControl when a Page is navigated to. The OnNavigatedTo function creates a popup, binds a Click event to the UserControl, and then shows the UserControl over the entire page. If the correct password is entered, ("password" in the example) the control disappears. You'll need to modify it for your own requirements, but it should definitely get you started.
https://skydrive.live.com/redir.aspx?cid=ef08824b672fb5d8&resid=EF08824B672FB5D8!343
You'll want to use the VisualStateManager and create some animation transitions to switch between the old and new components. I won't paste the code here for brevity, but if you check out:
http://visualstudiomagazine.com/articles/2011/07/22/wcmob_visual-states.aspx
You'll see a simple example of switching between two UI components on a single page within a Windows Phone 7 PhoneApplicationPage. In your scenario, you'd use this paradigm to create 2 animation storyboards, one for showing an overlay control and one for settings the 'disabled' property on the main grid.

silverlight combobox - highlight a few items in the popup list

I'm wondering if I can make fake sections in the popup menu:
The rule would be, if the 5th character of the displayed item is different from the 5th char of the previous item in the menu, it has to be highlighted
What do you think?
Thanks!
To achieve this would be a hack.
Normally the items that appear in the popup part of a combo box will be an instantiated data template, and each gets its own data item and has no clue or knowledge of the other items in the list, so you couldn't use a converter or anything else to achieve this behavior.
What you could do though is inject (attach) your own control into the popup part of the combo box, and take over the rendering of the data items. How you do this will depend upon which combo box you are using (i.e. MS or some other vendor's) and would be a whole new question.
Would that be easier if I were to create my own combobox as follow:
a TextBox associated with a Button that when pushed would popup a datagrid in which I could implement this conditional formatting?

Resources