C# Winforms Custom control help - c#

I am looking for a free control in C# which allows me to show a set of images in a List like a preview (Eg PDF pages preview). I tried ListView control but it does not allow me to set bigger image size. Please advice

You can use a ListView-ImageList combination to achieve that purpose.
Just set the ImageList's ImageSize property to something large, say 96, 96 and set the ListView's LargeImageList property to the ImageList.

Have you tried using a repeater?
here's a link returned on the first page of a quick google search that demonstrates one way to do this: http://www.vbknowledgebase.com/?Id=157&Desc=Asp.Net-Image-Dropdownlist

There is the ImageListView control. (I am the owner of the project.)

How about a Panel with images in it? You can set it up to render as a scrollable div (if you're targeting ASP.NET, which I think you are), or if this is WinForms, you just set it to have scrollbars.
Understand, though, that unless you have pre-made thumbnails for your images, showing a preview of the image will require loading the whole image and downsizing it to show as a thumb. So, except for the real estate it will take, you may not be saving much by "previewing" images.

Related

Exporting all content of ListView as Png

I'm building an app that contains a kanban board which I would like to export as a PNG image. The board consists of a ListView of the card status' (To-do, doing, etc ) and each one of those is ListView containing the cards of the same status.
I'm already able to export the board as an image using a RenderTargetBitmap, however, the output will have the content that's in view. Instead, I want to have an image containing all the cards.
I honestly don't think it's that simple since only the visible cards are rendered on the page in the first place but I want to know if there's a different approach to this problem.
This is how an exported board would look at the moment
Exporting all content of ListView as Png
Currently, UWP has no such api to get long screenshot. I'm afraid you can't approach with RenderTargetBitmap class.
And we can imagine, if we could scale current view, and make all content show in the current window, then we could get the complete screenshot. So we could try to place above all in ScrollViewer and set it ZoomMode as enable. Just call ChangeView method to give it a appropriate ZoomFactor value to display all the content in visible place .
<ScrollViewer ZoomMode="Enabled" >
<Grid>
<ListView>
Please note this way will disable the listview's ui virtualization. and if we scaled scrollviewer, the effective pixels of the current windows will be lower.
And you do want this feature, please feel free post your requirement with windows feedback hub.

How to set space between items in a checked list box?

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

Showing thumbnail of selected images in a desktop application using C Sharp

I have a desktop application in C sharp, in which I have to show selected images in thumbnail view ( the view will be some thing like the attached image). The selected image can be deselected using x (cross) button shown on image top. Can someone suggest me how this can be accomplished. I have seen this accomplished in ASP .net. But I have to accomplish this in C#. Any clue will be greatly welcomed.
Regards,
You can generate the thumbnails from the Image class in .Net (Image.GetThumbnailImage). As far as the layout you are showing here, you could use a FlowLayoutPanel, or some other type of panel (or roll your own) that would dynamically add the images to your form. From there you can highlight around the image and add your X control button in the OnPaint, just keep track of which are selected and which aren't via some container class (add the images to something like a HashSet (.Net 3.5 or higher) so that you can quickly add/remove them from the collection, and iterate it in the OnPaint.
My advise will be to create a custom control (or user control) that will encapsulate image thumbnail & its name. It will highlight & show cross when focused/hovered. Cross can be as simple as another image overlaid on thumbnail (showing/hiding in mouse over event). Then you just needs to create and lay out multiple instances of control in whatever manner you want.

(C#, WinForms) How to assign an accessibility attribute to an image in ImageList

I'm trying to find a way to make a screen-reader (like JAWS) to read out loud some text that is assigned to images in ImageList.
In other controls (like PushButton) there is "AccessibleName" property, that when contains text, it's being read by JAWS.
the ImageList consists of four icons that represent priorities, and no text is displayed near them.
Is it possible to do it?
Can you think of any other creative solution?
Thanks, Yaniv.
An ImageList isn't really a visible control - it is a resource. IIRC you would have to associate accessibility concerns with the control that is using the ImageList.
Is there not an AccessibleName or AccessibleDescription property on the TreeNode object? Then, as you are building the dynamic node, and associating a specific image to it from the imagelist, you can also have some code that 'calculates' the accessible text for the image and sets one of those properties.

C# ListView: ListViewItem offset possible?

I was wondering... I have a WinForms System.Windows.Forms.ListView with a bunch of ListViewItems that I'm drawing using the View.List style. Each ListViewItem has a "SmallIcon" that I fetch from the ListView's SmallImageList.
My problem is that the icons are showing too close to the border on the left. I've tried to change the bounds and the ListViewItem's Position property to no avail.
Is there anyway to have some kind of offset to ListViewItems?
The Win32 listview control doesn't have any setting to increase the space between the icon and the label (in any view, not just List). Setting ListViewItem.Position does nothing when the ListView is in List view.
A low-tech solution would be to simply prefix every ListViewItem's Text value with a single space. Slightly ugly, but oh so easy to do.
If you really want to have pixel level control, you will have to owner draw it. As always, if you are doing anything with a .NET ListView, ObjectListView makes owner drawing your items trivial.
As mentioned already, prefixing the text of all your items with a space is a super simple way to add padding. This has a pretty significant drawback, however. Once you do this, you lose the ability to find items in the ListView by simply starting to type their name while the ListView has focus.
Try adding white space to the left of your small images.
If you're using 16x16 images change to 24x16 for example by adding 8 white (or ListView Background color) pixels to the left.
If you are in ListView View LargeIcons then you can postion the text using item.position
A screenshot would be nice for an example to see exactly what you're after.
Funny thing... the Windows Explorer uses the ListView to display files and folders. i usually run my view in Report or Detail mode. i just switched it to List view mode and see the exact problem that you're describing! Yikes. Might be a bug with the Win32 object and that particular view type!
A quick workaround might be to use a Report style for the ListView with a single column or perhaps implement something yourself. The FlowLayoutPanel in .Net would work very nicely as a starting point for a custom list view.
As you are using the View.List style, I suspect you'll either need to implement some custom drawing or consider padding your images. You could also look at overriding the ListView control and manipulating it's bounds by overriding SetBoundsCore or SetClientSizeCore (or similar).
However, if the ListView were set-up for View.Details view, this could be done using the ListViewItem.IndentCount property:
The IndentCount property can be used
only when the View property of the
containing ListView is set to Details,
and the SmallImageList property of the
ListView is set. Source:MSDN
If you set the StateImageList property you can add a space of 16 px before the icons. I think you can adjust this additional space by loading an image with matching width as first entry into the StateImageList. But I have not tested this.
This thread discusses the opposite problem.

Categories