If not, what's the best way of sanitizing users' input (keyboard and pasting from the clipboard)?
DevExpress is releasing version 9.2 of their controls this week which includes a masked edit control based on RegEx:
http://community.devexpress.com/forums/p/78946/270208.aspx#270208
Aside from that you're stuck hacking KeyDown and TextChanged events to cobble something together. I've done a lot of that and I've got to say its not pretty and very hard to test! I'm not aware of a free control at the moment that does this.
Related
I want to take advantage of DateTimePicker's date validation, but the calendar seemed cumbersome to our customers for setting the date (they'd rather do it using just the keyboard, tabbing their way through the form).
So I took a long look at the documentation and found that one way to get rid of the calendar was setting the ShowUpDown property to true. So I got this:
However, our customers are now saying that they don't want to use the spin button, and therefore they don't want it to be visible/accesible. i.e. they want this:
However, if i set ShowUpDown to false, I'm back to the calendar. Is there another way?
Had to roll my own Custom Control. Luckily, some other guy from the team has already written custom controls so I have example code to get started. Anyway, what good is a framework if I have to do this kind of things myself? Hope they solved this in .net 4.5...
EDIT: Using a MaskedTextBox with ValidatingType = typeof(System.Date) is a better solution. Sorry .NET!
I have the word "subclass" in the title because that's the only idea I have for doing this, but maybe not?
What I need is to only use the years of a calendar control - I don't need either the months view nor the days view. I thought of writing a custom control that does this, but since calendar already has the very cool "Decade" view, I wanted to use that.
I tried handling the DisplayDateChanged event and forcing the mode back to Decade, but what happens is that the months show on click, and then disapear showing the Decade view again.
Any "interesting hacks" for doing this?
In C++, I always knew I can do a "real subclass" and intervene in the control's behavior - Can this be done?
Check out this article on styling for the Calendar control, it may get you started.
http://msdn.microsoft.com/en-us/magazine/dd882520.aspx
In order to make a convenient UI for an .Net 2.0 Winforms application I am working on, I have need for a control that I'm pretty sure goes beyond the "out of the box" behavior of any standard control. A mock-up of what I'm trying to achieve follows:
Mock up http://www.claware.com/images/temp/mockup.png
Essentially, this part of the application attempts to parse words into syllables from tribal languages (no dictionary to refer to; any and all unicode characters are possible.) By the time the user gets this far, he has already defined the vowels / consonants in his language and some other configuration. There is then an iterative process of (1) the application guesses which syllables exist in the language based on some rules, (2) the user refines the guesses, selecting the correct parsings or manually parsing a word, (3) the application "learns" from the user's feedback and makes smarter guesses, (4) repeat until the data is "good enough" to move on.
The control needs to present each word (the grey headers), then all the syllable break guesses (the white areas with dots separating the parts of words.) There is also a way to manually enter a parsing, which will display a text area and save button (at the bottom of the mockup.) When the user hovers over a guess, the background changes and "accept / reject" buttons appear. Clicking on the accept, or entering a manual parsing, removes the entire word from the list. Clicking the reject button removes just that item.
I'm by no means 100% sold on the formatting I have above, but I think you can get a general idea of the types of formatting and functional control I need. The control will also scroll vertically--there may be thousands of words initially.
My question for you experienced WinForms developers is: where to start? I would really, really like to stay within the .Net core framework and extend an existing control as opposed to a third-party control. (At the risk of starting a religious war: yes, I suffer from NIH-syndrome, but it's a conscious decision based on a lot of quick-fix solutions but long-term problems with 3rd party controls.) Where can I get the most "bang for my bucK" and the least reinventing the wheel? ListView? ListBox? ScrollableControl? Do I need to go all the way back to Control and paint everything manually? I appreciate any help that could be provided!
[Edit] Thanks everyone for the ideas. It seems like the most elegant solution for my purposes is to create a custom control consisting of a FlowLayoutPanel and a VScrollBar. The FlowLayoutPanel can contain instances of the custom controls used for each word. But the FlowLayoutPanel is virtual, i.e. it only contains those instances which are visible (and some "just out of scroll"). The VScrollBar events determine what needs to be loaded. A bit of code to write, but isn't too bad and seems to work well.
I would look at the TableLayoutPanel and FlowLayoutPanel controls. These will let you organize a series of controls with moderate ease in a vertical fashion. I would then create a UserControl that consists of a label and 2 buttons. The UserControl will expose properties like Text and events that are exposed for the button clicks.. For each entry in the list, you will create an instance of the UserControl, assign the text value, and handle the click events. The instance will be placed in the Table/Flow panel in the correct order. Both of those layout panels do allow for inserting items between other items so you can add/remove items from the list dynamically.
Edit:
Given the length of what you are trying to render, I would consider using the DataGridView and do some custom rendering to make it perform how you want it to work. Using the rendering events of the DGV you can merge columns, change background colors (like highlighting the dark gray lines), turn on/off the buttons, and handle changing the grid into edit mode for your rows to allow modification or inserting of new values. This method would easily handle large datasets and you could bind directly to them very easily.
Well, this certainly looks like a candidate for a custom component that you should be creating yourself. You can create this using standard .Net drawing commands along with a text-box, and a regular button control.
Now you want to find out where to start.
Create a Windows Forms Control Library project.
Drop in the textbox and the button control.
The panel drawing code should preferably be done by code. This can be done using the regular GDI+ commands.
Edit:
Here's another idea, and one that I've practically used in my own project with great success.
You could use a web-browser control in the app, and show your data as html. You could update the source of the web-browser control based on the input in the textbox, and clicking on the links in the web browser control will give you the event that you can trap to do some action. Your CSS will work.
I used this technique to build the 'desktop' in an app I made called 'Correct Accounting Software'. People loved the desktop so much that it is one of the best loved features of the app.
Here's how I would do it:
Create a custom control. In this custom control, have a ListBox atop a LinkButton, and when the LinkButton is clicked you can make it give way to a TextBox. The ListBoxes will have the top row unselectable... you can probably get the rest from there. When you get your list of words, fill a Scrollable of some kind with one control for each word:
(foreach String word in words){
myScrollable.add(new MyComponent(word));
}
From there, I'm not sure what you want to do with the boxes or the data, but that's my initial idea on the UI setup.
Use the WebBrowser control and generate the HTML markup into it using DocumentStream or DocumentText.
I am searching for a DateTimePicker control which can be used as a textbox so user can enter date/time data at will (ie; type in the string "11/09/2008 12:30:00") or can select date/time from a drop down list that contains a calendar/time box (what i meant is that this control can provide both options as mentioned). If you have found such a flexible control (and free too) please give me the needed information to obtain it.
There's the DatePicker and Calendar controls from the WPF team, but I don't believe they handle times (as in your example) - just dates. Worth a look though.
Have a look at this WPF Date Picker question.
Cheers
Telerik has a decent DateTimePicker control but it's not free.
Old question, but for anyone interested... Extended WPF Toolkit™ Community Edition is free (also has a premium option) and contains a DateTimePicker which I have found to be very useful in WPF!
I am not sure whether you don't want to use JQuery or not aware of it. But here is this free/open source date time picker from JQuery which does exactly what you are looking for, plus lot more.
I am looking for a WinForms treeview control with following requirements:
Should be not so hard to write code for it (most tree/list combinations are way too complicated)
Should have some sort of easy drag and drop capabilities (including a vista-explorer style drop marker)
Should be free or at least affordable
Should provide some freedom of text/color/style/etc. of the treenodes (classic "outlook bold with blue numbers style)
Any ideas?
thx
i would recommend http://www.lidorsystems.com/ !
Another interesting alternative is TreeViewAdv, as suggested in another thread.
C# replacement for standard Treeview?
I'm a big fan of SandGrid by Divelements. I use it for all my ListViews and TreeViews. It even supports both at the same time (a TreeView with columns). I find it easy to use and very fast.
I think the standard WinForms' treeview control will do everything on your list. I don't know what the second item refers to as I've not used Vista. It's declared as System.Windows.Forms.TreeView and is available in VS200*'s form designer. I can't think of any simpler way of doing tree views.