Background:
A while back I designed a custom User Control that I have since embedded in my grid control (ugPoints) using the UltraControlContainerEditor
(See this thread for the details & help I got from this one - http://es.infragistics.com/community/forums/t/84111.aspx )
Dim ucce As New UltraControlContainerEditorDim ucKV As New ucKVDropDownucce.EditingControl = ucKVucce.EditingControlPropertyName = "Value"With ugPoints.DisplayLayout.Bands(0).Columns("kV") .EditorComponent = ucceEnd With
My custom control ends up displaying a 2 Column Grid mimicking a drop down control - the issue is that the grid column width (in ugPoints) is too narrow to show the entire width of the custom control.
Is there a way to tell the grid or the UltraControlContainerEditor to have a display width greater than the column width (i.e. to behave more like the UltraDropDown control)?
Or am I making this a lot harder than it has to be?
Thanks in advance for any assistance.
Hi,
Well... the easy solution would be to simply set the Width property on the column.
But I assume since you are asking the question that that isn't working or is not sufficient for some reason. But I'm not entirely sure why that would be. Do you want the main grid column to auto-size based on the columns inside your user control?
If you autosize the column in the main grid, by double-clicking the right edge of the column header or calling column.PerformAutoResize, then what the grid does is it uses the GetPreferredSize method on your user control. So to make autosizing work, you would have to autosize the columns in your UserControl grid, get the combined widths, plus any padding or scrollbars, and then override GetPreferredSize on your usercontrol and return the resulting width.
Hi Mike,
Thanks for the reply.
I knew there was no way I could really explain this so after I posted I made a quick sample app. When you run the App, the Column "KV1" is bound to my custom control, "KV2" is bound to a stock UltraDropDown - both of which are using the same List of Custom Object type as their data source.
In a perfect world I'd like my control to behave exactly like the UDD (including when the drop down button appears) but the specific behavior I'm asking about is:
When you drop the UDD - it's drop down width is wider than the grid column width which makes the multi-colum data easy to read / navigate
When you drop my custom control - it is constrained (crammed) into the grid column width making it nearly impossible to use.
In the real application, screen "realestate" is at a premium so making the grid column wider to in turn make the custom control wider is very much not a prefered solution.
In the long run I may be approaching the entire problem wrong. I think it would be much simpler to try and "extend" an UltraDropDOwn to provide the search/filter behavior I need for the grid but I also need this control to be usable directly on a form as well. I know the UltraCombo is for use on a form and that it inherits the UltraDropDown but I've no clue how I would go about developing a single control solution and perhaps that's not really even possible / practical.
Thanks again for your Time and Assistance
Steve
https://p2p.aep.com:443/AEPLargeFile/fileDownload.dsp?isEncrypted=true&isEnSet=true&fileStage=30&fileName=HnVQL2JWj82Jil7UKjzBiHZllwIFc1jWUhHJzb2a3dxkbYxO9SBibA%3D%3D&fop=c86bf950e7f511e3b51bfd68e7f9a2198&version=v2
Michael,
My apologies for not getting back sooner. I was pulled off onto another project this week and had not yert had time to get back to this code.
Uncommenting that code or manually setting the underlying UG width is not the solution to the problem because then the grid colum containing the custom control then has to be set at the same width in order to even see / access the drop down button in the custom control.
I am looking to mimic the behavior of the ultradropdown linked in KV2 - the grid column can be narrow but upon dropping the udd down - it displays wider than the grid column.
Thank you for your help
Hi Steve,
I wasn't able to run your project because it's missing a whole bunch of files (under the My Project folder).
But it looks like you are using a DropDownEditorButton to show a grid in the dropdown. The dropdown size is determined by the size of the control in it. So you have to set the size of this control. So you would have to determine the ideal size and then set the size of your grid control.
So what you would do is override OnBeforeEditorButtonDropDown. Then you would have to determine the ideal size of the grid. So you would likely want to autosize all of the grid columns to their contents.
ug.DisplayLayout.PerformAutoResizeColumns(False, PerformAutoSizeType.AllRowsInBand, AutoResizeColumnWidthOptions.All)
Then you would loop through the columns and sum up the widths. This is a little bit tricky, because sometimes the grid columns overlap, so you might have to make a small adjustment to account for that, subtracting 1 from the width of all but the first column. You would also have to determine the width of the scrollbars (if they are visible) and the borders (assuming the grid is displaying any).
So this is not a trivial undertaking.
Have you considered just turning on AllowRowFiltering in the UltraDropDown control?
Hey Mike,
Sorry the sample project didn't run. I double checked and it's not referencing anything outside the sample app and I thought I ZIPed everything but I've made a new one you can try.
I hadn't considered the AllowRowFiltering because I didn't think it would perform as I need but I am still playing with it now. I don't think I can get the exact behavior I need with just the built in row filtering and auto fill properties alone which is why I started down the (very rocky) path of creating a custom control.
What I have is a list of distinct single character "Codes" and distinct integer value Voltages (Below is a sample subset, you can find the entire list in the sample code) In my actual application these are loaded from a Database but it uses the same List(Of CustomObject) as shown here
The Controls Value & Display properties are both tied to the integer Voltage value and the behavior I am after is:
If the user types a single character and then:
- Drops down the list, the list will be filtered with any result where that character is contained in either the Code or Voltage columns with priority going to a matched Code (Ex if the user types a "1" then the top answer would be the 1 - 138 row, followed by the rows for 11,12,13,15,144,161 etc
- Exits the control (never drops list) - the control tries to match a Code and assume the value of the corresponding voltage, if no code matches, it checks to see if it matches a voltage, if there is still no match then it defaults to Zero.
If the user types more than one character and then:
- Drops down the list, same filtering behavior. Speed gain from searching one field instead of two is negligible in this usage
- Exits the control (never drops list) - the control tries to match a Voltage and either set's its value to the corresponding voltage or defaults to Zero if no match found.
I had wanted this to be a single control that I could use on forms as well as within a grid cell and I can see that this is turning into a very Non-Trivial task. I have pretty much reached the point of abandoning a single custom control and just writing separate code for an UltraDropDown for use in grids and an UltraCombo for use on forms. The underlying logic is the same and won't change often (if ever) so having it in two (or more) places, while not ideal, is acceptable.
I know this reply is kind of taking a tangent to the original question but I thought if I better explained what I was after you could tell me if this approach was all wet.
Thanks Again for all your help
Sample Subset (Code - Voltage)
# - 0
Q - 11
L - 12
K - 13
W - 15
H - 34
1 - 138
N - 144
A - 161
7 - 765
Here is a link to the new ZIP file; hopefully I got everything this time.
https://p2p.aep.com:443/AEPLargeFile/fileDownload.dsp?isEncrypted=true&isEnSet=true&fileStage=30&fileName=xZAOCbbBmIGJil7UKjzBiHZllwIFc1jWUhHJzb2a3dxkbYxO9SBibA%3D%3D&fop=ebe48500efe811e3b1eca7e4862a91e52&version=v2
Okay. How flexible are your requirements?
The requirements you listed here are very specific. You can probably acheive most of this using UltraDropDown. The only thing you won't be able to do is the first thing you listed:
n2dfire said:- Drops down the list, the list will be filtered with any result where that character is contained in either the Code or Voltage columns with priority going to a matched Code (Ex if the user types a "1" then the top answer would be the 1 - 138 row, followed by the rows for 11,12,13,15,144,161 etc
The AutoCompleteMode functionality on the grid column will get you most of the way there, though. Basically, the user could type a character and the dropdown will automatically show up as soon as they type and filter based on what they types. You can set the filtering to do a StartWith (default) or Contains search. The only thing it will not do is search two different columns. It only works in a single column. So that would get you almost everything you want, but not quite.
If that's no good, then an UltraCombo control with a dropdown grid is probably the way to go. But you would have to deal with the sizing like I described in my previous response. You should be able to do this with a single derived UltraCombo control for both a standalone combo and also embed it in the grid using UltraControlContainerEditor.
Actually that's the basis of the functionality I was aiming for.
It allows users that are familiar with the system to enter the codes and keep going and users not a proficient to enter a numeric value - and either way the numeric value is what gets sent back to the database.
Figures if I try to do something I have to do it the "hard way" - I'll dig in to converting my custom control to extending an UltraCombo instead of the UltraTextEditor w/ button.
Thanks Mike