Hello,
I'm new to your controls and WPF so for few days I tried to code something with XamlMultiColumComboEditor, and some problems has occurred.
1) How can I get a selected field, ie in a MessageBox, like MessageBox.Show(combobox.SelectedValue.ToString()); because SelectedValue is always null (I put this code in the SelectionChanged event of the control, that may be the reason) and others return me something I don't want and I don't understand.
2) Is it normal that I always have a blank column at the end of my rows ? If so, why, and (how) can I get rid of it properly ?
3) My control displays 3 columns from a dataset. Everything works well until I click on a row, then the text field displays only one value (the last one). Same question as above, but to display the whole row.
4) How can I change the name / title of headers ? They seem to take my database's fields' names, and I don't want that since it's camel cased but not really pretty.
Although this control (and some others) are really usefull, those problems are annoying me, but maybe I didn't search far enough...
And just to be curious : before I discovered Infragistics' controls, I tried to gather about 36 000 rows from my database in a combobox. It took so much time to initialize... and I was so impressed to see yours takes only... almost nothing ! How did you do that ? I struggled for a while to find a way to solve it !
Thanks for your help !
Hi Collin,
Here are the answers:
I would encourage you to take a look at the samples for this control so you get better feeling of it. Here's a link to the Silverlight samples for this control http://es.infragistics.com/products/silverlight/multicolumn-combo. Don't mind it is Silverlight since the control is the same. You could find the samples for WPF if you got them installed. The SL ones are just more easy to reference here :)
Finally XamMultyColumnComboEditor is so much faster than the MS ComboBox because of the UI Virtualization it uses. So basically when you bind the editor to 30K rows when firstly opened the MS ComboBox generate a Control representing every single item so that's 30K UI items generated on opening even though only couple of them are visible at a single moment. The XamMultiColumnComboEditor creates just enough UI items only for the items that are currently visible.
Hope this helps,
Hello and thanks for your answer, it helped me in some ways.
I found and tried this code to get the selected text by users :
SpecializedTextBox tbV = Utilities.GetDescendantFromName(cbVille as DependencyObject, "TextBoxPresenter") as SpecializedTextBox;
It works, I'm able to display the selected field in a messagebox, but it looks pretty scary. Why do you do that, what is the purpose of a DependencyObject, and what is the difference between a SpecializedTextBox and a basic control ? Do I really need to do everything of this to get the clicked text ? And the main problem remains, it doesn't display the whole row. Even if it's not important in this project, I would like to know the reason, if I can fix it.
Not sure how I can use the selectedValuePath here since I don't have a class to bind my combobox, it is just filled thanks to a query and a dataset. Maybe by giving it one of the query's fields as a value ? Anyway, I see how it works, I tried it for another test project, but this one doesn't fit. Thanks for your link, I'll check it out.
You're right, I didn't unchecked the AutoGenerateColumns property as it worked well, and I had this idea too that it may have been because of that. The fact is I already checked the null value in my object (a query's result), and there's nothing about it inside. Even the header is empty. What is weird is that it occurs only sometimes. No reason, I just launch and re-launch my project and it happens or not. However, I wish I could have kept the AutoGenerateColumns property to true, since it's easier. So there may be a reason about that ?
Ok thanks for your tips, I think I got it, but it's only if I set my columns by myself, and I would like to avoid to do that when it can do it for me.
Another problem has occurred though : I wanted to clear my combobox (the same as above), but cb.Items.Clear() doesn't seem to work. Any reason ? I then tried to read through the Items list with a foreach loop like that :
foreach (Infragistics.Controls.Editors.ComboRow item in cbRSociale.Items)
{
MessageBox.Show(item.ToString());
}
And... I only get "Infragistics.Controls.Editors.ComboRow". I suppose I can't cast it to a string because the row can contain anything like an image, ok, my bad. But what if I want to check a combobox filled of strings (ie with only one field per row) ? Can't I set a value to a field for each row ? Anyway, the main question is : how can I clear my combobox ?
Your controls seem to be very very different from MS's, it's painful sometimes even if it's magic the first time. Any reason about that ? Besides the rapidity to deal with 30 000 rows haha !
Well, thanks a lot for your help !
Hey yes, long response because I'm (just a bit) curious :)
Thanks for your sample, I tested it but it still has an empty column. Not sure it was your purpose to show me that at the beginning, but here's a printscreen of what I got.
Link : http://1drv.ms/1odOdte
I provide you a sample of mine where you can see what I did in my main project. You'll have to change the connectionString in the Connection class, and fields / table names in Sql.cs and the main window.
Unfortunatly I can't wrapp my DataRowView object into a custom class, because if I do so, I'll have to do that for everything else, and there's too many tables that I deal with. I try to keep my code as light as possible, mainly for my eyes, but for the next one who will update my code one day too. Plus, I'm not sure how I can do that easily, I feel that is like another "hack", and I don't like that.
I gave you an example in my code about the 'selectedValuePath' problem in order to give you more info about what I want to do.
Actually, even if the empty column still appears sometimes, it doesn't really bother me since I merely notice it. It's just weird, and I don't like to ignore "weird things" in my code :) That's not so easy. So as I don't have any CheckBox column, I'm still wondering why.
Of course I could use your option to generate those columns by myself, but... it is supposed to do that, and I'm reluctant to re-write something that already exists because of a bug or anything else. I will if I have no other choice of course.
Thanks !
So the mysterious column is the CheckboxColumn that contains a checkbox for each row and the checkbox is checked if the row is selected. You could enable/disable it by setting the XamMultiColumnComboEditor.CheckboxVisibility=Visible/Collapsed. I could not imagine this column to be there in one run of the app and to be gone on the other. I was not able to reproduce it either.
On the other issue I could not think of other way to make the editor show the whole row text in the text box part. I don't see why you would need to wrap everything else. I think it could even be done with convertor. Well it surely introduces more complexity but I honestly can't think of other less complex way to achieve your scenario. I could try to build you a sample if you're willing to consider it.
I couldn't quite catch what exactly do you mean by the following paragraph:
"Of course I could use your option to generate those columns by myself, but... it is supposed to do that, and I'm reluctant to re-write something that already exists because of a bug or anything else. I will if I have no other choice of course"
Usually you don't want to have too much columns in the editor, since it's not a data grid and just a selector. On the other hand you want to define more user friendly column names than the column names that are coming from the data base. Defining these columns isn't that hard. AutoGenerateColumns option is more like a convenience for the developer during the development process but you need to define those columns to the right way when you are shipping.
I've attached a modified version of your sample(I didn't use the Sql and connection classes since its practically the same if you define a table in the code behind and this way the sample is much more tranferrable) - I've set the SelectedValuePath(this solves the issue with the hack accessing the SpecializedTextBox and getting the text from it) and the DisplayMemberPath.
Regards,
Hmm that's interesting...
I didn't get what you said, I mean, this column is on the right side of the combobox, and the checkboxes' one is on the left side, so they are two different columns. I know that I can disable the checkboxes' side, but I'm actually talking about the right one. Maybe I didn't understand everything here.
Actually there's no point for me to display the whole row in the textfield for the moment, it was just to get every values inside (ie in a MessageBox) in order to do something with them. Thank you then for your sample, I see how you can do it and it may help me in some ways, so you won't need to build me another sample.
I'm just saying that if the AutoGenerateColumns property exists, I don't need to do it by myself, even if I don't have a lot of choices here. No big deal, my user doesn't really need titles I guess so I didn't really want THE solution for this problem but just answers to understand well what how it works. So as I see now in which cases I can use this way, I can say it's answered.
And sorry about my code, I never used DataTables before, and your code will help me if I want to do it later (it seems easier to use for some tests).
The right empty column is the filler column it fill up the remaining space till the end of the dropdown. You could access it through XamMultiComboEditor.Columns.FillerColumn and set its Visibility to collapsed or style it by setting a style to its CellStyle property.
I'm glad I was able to help. If you need any further assistance don't hesitate to ask.
Ah yes, ok, I'll try to change it through my code. Weird behaviour though, it would be better if other columns' size was adapted to the remaining space...
Thank you !
Ah yes indeed, I knew that but I totally forgot it. Your answers were really helpful, thank you again !
This could be easily achieved by specifying the Width of the columns. Each column has a Width property. It is of type ComboColumnWidth - you could check what's the meaning of each value at the following XamGrid help page - don't mind that its XamGrid help page - the ColumnWidth concept is the same. So if you want your columns to take all of the available space you could set the width of each column to a Star value this way all the available space would be evenly divided between all columns. You could, as well, set the Width to a Star value to only one of the columns. This way only this column will take up all of the available horizontal space.