I'm trying to set the Height of a ComboBox in C#.NET CF / WinCE6.
So far I managed to do it by using the MessageWindow.SendMessage() with CB_SETITEMHEIGHT. The issue is the ComboBox gets to its initial Height when being clicked.
Is there a workaround for this ?
LE: How would this affect performance, considering the ComboBox might store 1k entries ?
Thanks.
One thing you could do to overcome the resetting of the combo box height is to set your SendMessage solution on a timer, say once every 250ms or something like that.
Btw, are you talking about DropDownHeight or the actual control's height? If it's the latter you can actually resize it by increasing the size of the font. That's what the combo box' size is keyed on and why you're losing that dimension upon interaction with it.
But your plan to store 1k entries in a combo box on a handheld device is a usability issue. It's hard to pick things out of a list on a combo box when there are few items to choose from. If you put 1k items into the list you will be forcing the user to scroll which is a very tough thing to do even for experienced Windows users due to the size of the scroller, the stylus and the weird nature of some of the touch screens out there. You should think about a filtering process whereby you limit the number of items in the combo box by several orders of magnitude.
Related
I would like to simply enable autosizing on my datagridview (or similar behavior). I want some columns to grow and fill all available space. However, I also have some columns that I want 100% fixed and to not grow at all, and I can't get this particular behavior.
Unfortunately, no matter what the fill rate is, I can't figure out how to lock the columns I don't want to change. So far, I have tried:
Setting FillWeight to be extremely small on the columns I want locked. Unfortunately, this just causes the column to become sized too small off the bat, regardless of its initial width setting.
Setting Resizable = DataGridViewTriState.False only prevents the user from changing the size of that column. It still resizes automatically when I change the window size.
Does a solution exist? If I can't find one, I'll need to write up my own implementation, triggered using DataGridView.Resize I take it.
I see, MinimumWidth needs to be leveraged as part of the solution. FillWeight = float.Epsilon, MinimumWidth = 50 seems to do the trick.
I'm developing a windows form application using c#. How can I set a space between items in a checked list box?
You can't, increasing the font size is all you got. Not exactly a control that's suitable for a touch screen. You can re-implement it with ListBox.DrawMode and ControlPaint.DrawCheckBox().
The better selection here is a ListView with View = Tile, easy to hit with your thumb when you make the tile big enough. You can't use ListView.CheckBoxes anymore, using an icon is a good choice. Also automatically takes care of the user only selecting one item.
Looks like you could go with a ListView (which always always always ist the better choice anyway) and a (dummy) imagelist. See
here and here.
Just tried it and it's really easy: Add an imagelist to your form; set its imagesize width to something small and its height to your liking and apply it as the listview's stateimagelist. No need for any actual images.
No need to go for tiles and you could add prices in a 2nd column, even with a different font.. ListView rules ;-)
Let us see the final result! Yumm!!
Under the Behavior Properties, look for ColumnWidth
I need to create an app for TV guide. Requirement is that UI must be a copy of one you can see here: raspored.bnet.hr. As you can see, there's a lot of data. So, basically it would be a large scrollable table. Since there is no such UI control as table on Windows Phone, I found out that the best approach would be to create one vertical listbox with horizontal listboxes as its items. This is all ok and I'm able to create it. But, to make it behave like a table I also need to make these horizontal listboxes scroll in sync, not to scroll one row at a time. Then I disabled horizontal scroll on horizontal listboxes, and enabled it on the parent (vertical) listbox and while it gave the result I wanted to achieve one big problem came up - UI virtualization. I know ListBox has UI virtualization enabled by default and I can see it while scrolling on vertical listbox, but when I disable horizontal scroll on horizontal listboxes, performance is really bad, and sometimes there's an OutOfMemoryException. I understand why this happens because when I disabled horizontal scroll, those listboxes didn't know which items are on screen anymore, so the loaded all of them into memory.
What I also tried is to leave scroll on every listbox so they have UI virtualization, and then place ScrollViewer above them. Then I tried to listen on Manipulation events on scrollviewer and progamatically scroll all of the listboxes as needed. This didn't work good, first of all ManipulationDelta event doesn't appear to fire frequently enough to make scrolling smooth, and I think there could be a performance problem with calling ScrollToHorizontalOffset on ~180 listboxes.
I also tried the LongListSelector from WP8 as I read that it has much better UI virtualization and should be used instead of ListBox. The problem with this is that I couldn't make it scroll horizontally. Is it possible at all? I tried to wrap it into ScrollViewer which can scroll horizontally and it's working, but only if I set fixed width on LLS.
I also tried Telerik's RadDataBoundListBox and the problem was similar, I can't get both horizontal and vertical scrolls on the same listbox. So I could only get that each list scrolls on its own.
Can someone tell me if they had similar situation and what would be the best approach to solve this? I believe I'm not the only one that has this requirement to implement large scrollable table.
Thanks
UPDATE:
I'll just inform you that I didn't find a proper way to implement this, instead I've done it in HTML with WebBrowser control. Seems like IE already has UI virtualization implemented so it can work with large pages very well.
May be in your listbox there are images? and Out of memory Execption will occur you can do 2 things:
Don't load data in one time use BackgroundWorker
Have one local image in the App of the image you are downloading and set it as default image & when you scroll to some 50 values in forward clean the image Url to local and when it comes back give again the image url you want to show .
Because i have used it to scroll around 20k values.
I'm building a Windows Store App that uses a GridView to show a list of items (basic, out of the box template). I would like to know if I can get the total width that all the items take up.
Right now I'm taking the number of item columns and multiplying it by the total width of one of the items. This is working, but it requires that my code behind knows way too much about my view. I'd like to find the one property that has the width and just bind to it.
Thanks for any help!
Here is the code that I have to get the column width of the GridView
(itemGridView.ItemContainerGenerator.ContainerFromIndex(0) as GridViewItem).ActualWidth
I don't have a good way to get the number of Columns, so that would also be helpful
The ActualWidth property of the GridView should contain the information you are looking for.
If not, you could try to call Measure on the gridview to let it perform the required layout calculus and output its desired Size.
I'm still getting to grips with C Sharp and .NET and I am working on an application to display data being continually read from a USB device. I have all the USB code working and it is receiving the data updates every 5ms. The data consists of a set of sensor values for a number of units, say 50 units with 12 sensors per unit.
Currently I am using a ListBox object to display 50 rows of data. I'm setting the listbox mode to OwnerDrawFixed and my datasource to my data array of objects that represents the data read from the USB device (one object per row of the ListBox) and I'm using the DrawItem event to actually graphically draw each row of the list box as requested by the listbox (I'm doing it this way to enable text colouring, formatting, tidy layout etc).
In order to get the ListBox to refresh the data being displayed I'm calling periodically calling Invalidate to force it to redraw, but this is horrendously slow, and flicker unacceptably even at low frequecies such as 1 second updates never mind getting anywhere near the 5ms refresh of the sensors.
Can anyone suggest a better approach to updating the data on screen, perhaps one where I'm not drawing everything everytime or perhaps a way to tell the ListBox to only redraw a single row perhaps if the data on that row has changed?
I'm not tied to a ListBox in anyway, it's just my unfamiliarity with the .Net framework - perhaps the best solution might be to render everything to a bitmap and then blit it to the screen in a single action.
I've already read a similar question but the suggestions in there didn't really help...
c# - fast ListBox data update
Any alternative suggestions from experienced .net developers greatly appreciated...
Inherit the ListBox control and enable double-buffering is, I think, your best bet. I don't know how the ListBox paints but that should reduce flicker.
(If that doesn't work, a hack is to invalidate only a tiny rectangle on the corner and hope it paints properly. That most likely won't work with the original set of controls, though.)
It's very difficult to make a recommendation without knowing what you are doing. You might explain what your "data", "sensor values" and "units" are. In general, graphics are better for showing large data sets than vast lists of numbers.
If this is some kind of transient data, like sound intensity, you might consider a VU-meter kind of display, like in a music player.
If you are trying to track trends or changes, consider a sparkline or graph.
If you are trying to show correlations between data, consider a spectrum or XY graph.
In WPF you can fill ListBox at the beginig and after what just send data to layout acynchronosly.
If its posible use WPF you should try. Code is triviale when you have constant emount of data items.
For those who are interested in the solution that worked for me both solidly flicker free and fast.
I simply use a Panel control to represent my table in the design view, then in my code I have a method which is triggered by a timer every 1ms (though in reality I can't seem to get it faster than every 16ms - which I guess is probably linked to the 60hz vsync refresh of the monitor because I'm doing a graphical blit).
I grab the bounds of the panel, create a bitmap of matching size, draw my data to the bitmap using the various graphics commands (such as DrawString) then I blit the resulting bitmap to the panel control. This works well if I then subsequently resize the window as the panel is resized and my bitmap is accordingly resized.
This also works fast, and in reality is no more work than the previous slow/flickery solution using a list control, however it is to be noted that there is not support for selecting rows etc (as this app was only using a ListBox to display data).
I'm now seriously considering mini techs suggestion for future listbox work as this work around works fantastically well, and subclassing the ListBox (rather than basing it on a Panel control) would allow me to inherit some of the row selection stuff etc.
Thanks for all the suggestions,
Rich