I'm using the ObjectListView control from here.
I'd like to detect when a user right clicks the headers and hides or shows a column. Basically a ColumnVisibilityChanged event. The reason I want to detect this is to save the visible columns between sessions.
The ColumnWidthChanged event fires when this occurs (not on the column that has been removed), so I could iterate through AllColumns and check the value of IsVisible. However, that seems hacky and I'd like to avoid it. Also, that would get run several times when it didn't need to.
Anyone know of a better way of detecting a column being hidden or shown?
Well I found a solution that wasn't quite what I was looking for, but possibly better.
ObjectListView has SaveState() and RestoreState() methods as described here.
Related
I came across a tutorial and some example code for an audio converter. You select the format you want to convert to from a drop down, and when you do all sorts of options appear in a previously blank area, different options based on the format you choose. It's called Audio Converter .NET and is from same author as Audio CD Ripper .NET. I can't find the tutorial, but here is a screenshot.
See how on the right there is extra controls that are not on the left. I was experimenting trying to add another category. I added it to the dropdown, but am unsure how to make it so certain fields come up when it is selected.
I understand that they create those controls for those items, but I don't see how they call the correct one when the combo box selects something. I see controls are created, but if I try to duplicate the controls into another entry in the combo box they don't show up for either the new or old one I was duplicating from.
What's the best way to go about achieving something like this?
Thanks
The easiest way is to create the controls needed for every option in the dropdown inside a panel, and simply turn it's visibility property from false to true whenever it's corresponding option is selected using the combobox's SelectedIndexChanged event handler. (And don't forget to turn the current visible panel's visibility to false)
I'm displaying incomplete datasets in a listview.
When an item gets selected (doubleclicked or highlighted + enterKey),
I want to open a form, that allows me to add the missing data.
I checked the doc-page of ListViewItem and found that I should probably either use .OnSelected()-Method or .Selected-Event. However my IDE(#develop) offers neither of those, just a property called Selected Adding hte System.Windows.Controls-Namespace didn't change anything, though some googling suggested otherwise.
My question is:
How can I get access to these Methods/Events or is there a workaround, i.e. a ListView-Event that offers similar functionality?
Nevermind,
I used the ListView.ItemActivate-Event.
I'm trying to add some extra logging to my C# winforms application. I have a few data bound forms that all the database stuff is managed by a binding source and some typed datasets/adapters.
With this setup, it's kind of difficult to tell when something is changed, I'd have to manage each field and keep it's previous value. Is there a way I can hook into the dataset and tell when something is changed? I know datarow's have a RowState enumeration, would that be a good place to start? I looked into the binding source's DataMemberChanged event but it never fired so...
To get the original value of an updated Data value you can do this:
<DataTableRow>[<DataColumn>, DataRowVersion.Original]
To know what has changed look at the DataSet.GetChanges method. The example shows how to get the changes and go through them. I also have an old example here that uses a DataTable and shows how to do a comparison after a merge. It inspects the RowState and shows the changed values etc. It's near the bottom of the page and it's in VB since the OP was using that, not C#. I'm headed out now so I can't provide an equivalent translation but it should be pretty straightforward to glean some useful techniques from.
You can use the RowChanged event, the RowChanging event, or any of the other events raised by a DataTable.
I'm hopefully missing something extremely obvious here, but for the life of me I can't figure this out.
I have an AutoCompleteBox control that is retrieving results by way of an asynchronous call, although I can't find a reliable way in which to know when a user has selected an option from the list of returned values. I've tried hooking into the SelectionChanged event, but that fires on every movement within the autocomplete's drop down list, when what I actually want to know is when a user has definitively said "Hey, that's the item I want!" by either clicking it, or selecting it with the return key.
Any advice would be greatly appreciated as this is starting to drive me a tad crazy now. =)
Thanks
P.S. The SelectionChanged event arguments provide AddedItems and RemovedItems, but don't give any direct indication of the type of selection I'm looking for.
There isn't a specific event that indicates that the used has specifically plumped for an option rather then merely browsing.
For you scenario the closest you can get is DropDownClosed or even LostFocus events then access the SelectedItem property.
If you are using the Telerik AutoCompleteBox, perhaps the "OnEntryAdded" event is what you are looking for. I see this question was asked over 4 years ago so perhaps this event didn't exist back then. I just updated to the latest update of Telerik controls (2014 Q2). Here's a quick example. I removed the properties that we're not discussing here to clean it up but, obviously, those will need to be added back in unless you're setting them in code (e.g. DataSourceID).
Source Page:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" OnEntryAdded="RadAutoCompleteBox1_EntryAdded" >
</telerik:RadAutoCompleteBox>
Test Code (in VB):
Protected Sub RadAutoCompleteBox1_EntryAdded(sender As Object, e As AutoCompleteEntryEventArgs)
MsgBox(e.Entry.Text) 'This is just to show you the DataValueField in your dev
MsgBox(e.Entry.Value) 'This is just to show you the DataTextField in your dev
racbCustomer.Entries.Clear() 'This will wipe out the selection(s)
End Sub
Im trying to emulate a 'find as you type' function like that of the address bar ("awesome bar") in FireFox. I want a suggestion box to appear below a textbox, and the suggestion box contains strings that contain what is in the textbox. I looked at the autocomplete feature of a normal WinForms textbox, but it seems to only search the beginning of the strings.
Has anyone here built or have experience with implementing something like this?
edit:
Some clarification- It is a WinForms project.
It needs to search inside a string, not just the beginning (which is what a normal textbox does if i recall correctly). And the suggestions should be displayed in a popup like a textbox autocomplete.
You need to handle the TextChanged event for your text entry field, and when the text changes, start a new thread running that will apply the new search. If the text changes before you get your results back, just kill the thread. If the thread returns results in time, display them.
You can get slightly more advanced (e.g. wait for a short time after the text changes so that the user can type a word without you triggering off loads of useless threads) but essentially that's it.
There was a discussion earlier on this topic where the author concluded that you are better off doing the whole thing yourself.
How can I dynamically change auto complete entries in a C# combobox or textbox?
I did something vaguely similar, but more like the iTunesĀ® search box than the Awesomebar. My control used the textbox to actively filter a grid; so it wasn't for autocompletion.
...but... basically I had a DataView of all eligible items, whenever the TextBox's Text changed I'd update the Filter to hide all non-matching items. It worked well and might suit your needs for filtering the data--but not sure how to go about using it as an AutoComplete source for the textbox.
I have done such a thing for an app of mine not too much time ago.
What I did is make my search function in a new thread, so every time I typed a new letter, it called the search function in another thread, so I could keep on typing.
I can post some code if you need, but this should be enough to get you started. :)
Hemmed and hawed about deleting this after I noticed the OP edit mentioned winforms, but I think it'll be useful to anyone who comes here looking for the same but for asp.net apps.
Just because nobody has mentioned it yet, for a webforms app you absolutely want to do this with ajax (.net controls or pure JS, your choice). The feature is often called "autocomplete" and the one thing you don't want it to be breaking the seamlessness by making server round trips at the page level.
I suggest you look at this and this.
I've used Search As You Type in C# and How do I make a Textbox Postback on KeyUp?
Basically you use the keyup action to call a postback thats attached to the trigger to the update panel. then you do your update in the textbox_changed event with the dataview or whatever your backend looks like.