I want my ListBox to have columns, and one of those columns have to be a clickable URL.
How can I achieve this?
You can't do it in a ListBox. You can create your own control, or settle for another existing one. Based on the question, I'd guess you're not yet at the stage where you're creating your own controls. That takes a pretty good understanding of existing controls and the way they work under the covers (but a google search for creating Winforms Controls should yield plenty of instructions.) Edit added It looks like te 4th and 5th links in combination on that google search should get you what you need. You can create your own user control and then do an array of them)
As far as for other possible alternatives, have you considered a DataGridView? A DataGridView can have a hyperlink and it can have checkbox columns, so this would be one possible alternative.
Here's a link for having a Hyperlink column in a DataGridView.
Well, it is possible by using the CustomTabOffsets property (unreliable) or the DrawItem event. And implementing the MouseDown event to find out if that particular 'column' was clicked.
But there's little point, a ListView control with View = Details gives you the same functionality.
Related
Sorry but I am a newbie to WPF, I would really appreciate if you could help me-
Tag 1 in pic- Which control can I use to create a menu similar to that in the picture ? The closest I came was using a gridview within a listview but that ends up using a header for the gridview. Normal listview just highlights the entire strip and doesn't look good at all.
Tag 2 in pic // (No longer relevant, sorry)
Edit:
Looking for something simple like when using gridview with listview (as in pic below) there is automatically that standard window gradient & bevel effect etc. (As an idea, implementing it with buttons seems to cumbersome, first strip button border, then create all these effects.) So essentially anything already inbuilt in WPF.
Thanks for any help :-D !!!
ListBox or ListView are good controls to use. If it's just the 'pretty' factor you don't like, you can provide Templates to change the appearance. But functionally, ListBox and ListView provide the function of that menu.
When working with WPF, that should be your primary motivation when choose controls. What FUNCTIONS the way you want. You can always make it LOOK different with Templates, but getting the right FUNCTION is the primary goal for the control.
I have a DataGridView with 4 columns, one of them being a drop-down (ComboBox) column. The values in this column must be distinct so once a given drop-down values is selected in a row, I'd like it to not be available in any of the drop-downs in other rows. If a given value is unselected it should show up in the drop-downs again. I found a few articles with similar examples (1,2,3); however, all of them seem to involve subscribing to an event and manually populating the ComboBox.
Is there a way to accomplish this with databinding alone (maybe to an IEnumerable that's basically a all.Except(selected) Linq query)?
If databinding alone isn't enough, is there a better way to do it than the examples I found?
I'm a bit new to WinForms development so having trouble telling apart good advice from "yeah...that'll work, sort of".
I'm afraid your searching so far is correct - there is no better way to provide different lists to comboboxes in the same DataGridView column than subscribing to events (usually CellBeginEdit and CellEndEdit and then setting the DataSource for an individual DataGridViewComboBoxCell).
By way of evidence of this, I'll point you to the excellent DataGridView FAQ which was written by Mark Rideout, the DataGridView program manager at Microsoft. The FAQ has a full solution to your problem which is very similar to the links you post.
I'm watching at this page:
http://leeontech.wordpress.com/2010/02/01/summary-row-in-datagrid/
But they're using silverlight. I'm trying to create that user control to use it in a WPF C# application. I mean, not using Silverlight. But I can't find the namespaces: GroupHeader
I'm having a hard time with this. Thanks in advance.
Okay listen, you can totally do this, and in some scenarios I even recommend it.
Using a CollectionViewSource you can easily group your data. In the HeaderTemplate you can even use an Expander (or make your own) and get the animation you might be wanting. Here's a link to a sample of this: http://jerrytech.blogspot.com/2010/06/wpf-data-presentation-step-by-step.html
Using an ItemsControl, you can easily present your groups and details. In the ItemTemplate you can use styles make this look like a grid (if that is really what you want). You can also shift the style based on the type if your collection has more than one type of object in it (eat that datagrid!).
You can wire up your column headers (which will really be custom objects, right?) and handle all the sorting and stuff like that. They will look just right! Not like datagrid WinForm column headers!
Here's what's hard (not impossible, but more coding).
User-resizable columns.
User-rearrangable columns.
New record using bottom, empty row.
Paste from Excel (doesn't work right in datagrid either).
Select Row, highlight Column header.
That's it.
In lots of situations, this is really nice.
For the most part, I cannot stand the datagrid. Too restricting on UX.
I don't think you're not going to be able to get a silverlight control working in WPF.
Adding a footer row to the WPF datagrid is something a lot of people have complained about; it's ridiculous that it wasn't included out of the box.
See this thread from MSDN
Having been through this myself, your best bet will probably be to bite the bullet and use a third party control. It sucks, I know.
I have a data grid displaying results from a sql database. What I want to do is make it so that when I double click on a cell in the datagrid, a new window appears where that cell can be edited. I also would like to have all the info for that cell to be autogenerated into editable fields when the cell is double clicked. Any help or links to tutorials is appreciated. Thanks.
Try this DataGridView.CellDoubleClick Event
Did you consider using data binding? Simply put, you can bind your items list to DataGrid, and current item (eg. selected/double clicked) to your edit form's controls (TextBox, Label and whatever else you might have there).
Here are good starting points for windows forms: #1, #2. They cover problem you're facing. You can find data binding tutorials for ASP/WPF easily too, but especially first link covers entire concept pretty well.
I have 2 questions concerning C#.
1) I have a dropdown menu with several items in them. They are clickable, but when I click one, the older clicked one stays selected. Click another and the 2 original ones stay selected, and so on. I don't want this. What I want is that when I click one of the dropdownitems, that one is that selected one and the others are not.
2) I have a listview items on a winform. I loaded some string elements into it from a file. Now what I want to do is to be able to edit those strings and even add strings, just by clicking on the rows in which the data goes.
I've checked google and MSDN for these problems, but nothing helps, so I turn here.
2) The ListView does not support that type of action. You can roll your own (pain in the #$$), or perhaps a DataGrid would be better suited to your purpose.
EDIT:
This link may help
This one too
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
Please comment if you have any more information about #1.