I am interested in creating my very own control from scratch. (Yes, I know...) - here's what I was thinking, I'll only choose one of the following, but depending on the complexity, I think I am going to go with a TextBox or ComboBox:
TextBox
ComboBox
FormTyper
I made the third name up. FormTyper is simply a "way" of being able to click absolutely anywhere on the Form and just start typing, and the letters/numbers etc will appear as if you were typing in a textbox. This would be my ideal new project, I would love to do this, but I haven't seen it done before, and I'm not sure how to start.
Does anyone have any advice, suggestions, or really good, in-depth (but simple :P) tutorials/articles/code I can read up on/play around with?
Any help at all will be greatly appreciated.
Thanks :)
Jase
You picked the wrong kind of control to get started with. Making your own text editor from scratch is unreasonably hard. Seemingly simple things like displaying a caret requires pinvoking obscure api functions. Calculating where to show it inside of a string is very hard.
Pick an easier one to get started with. A calendar for example. Essential skills you'll learn is how to write your own OnPaint() method to give a control a visual appearance, how to do mouse hit testing and how to pick the right kind of events and properties to make the control useful in a program.
Related
Does anyone know how to collect the recently clicked 5 buttons, and save them to a new group in the Hometab for reusing? Using C# in VSTO.
It seems a simple thing, however, I find now way to dynamicly monitor the control event in the ribbon and get the ID.
Have searched for several weeks.
Thanks a lot if anyone can help.
Hmm I don't think it's possible or at least I don't know about any way how to do that.
First there is no way how to easily monitor which button was pressed by any API Microsoft provides. You know, there is no command there is called for every button where you can hook your code and listen. I know that out there are amazing tools that can help you with things I originally thought are impossible RubberDuck, Watch Dog, MZ Tools but first, they are mainly for VBA, second it's probably not easy solution that you are looking for.
You would probably have to - somehow - mimic Office ribbon by your own ribbon => way too much work, use one callback, monitor it and determine the last 5 buttons.
Then you would have to change the Home tab by changing the ribbon XML which has two drawbacks
1, I believe it's not possible adding/removing buttons dynamically (you can use callback to change visibility but for adding/removing there is probably nothing)
2, you would have to restart the Office application to see your changes
As you see I'm not entirely sure it's impossible but I do see it as way too much work.
Anyway I'd love to hear if there is a way how to do that, so please if you find any way do let me know. Thanks
Is there a way to hide the whole "tabs" strip that runs across the top of a DockPanel? I found a very old page from '05 that said to set the DockPanel.SdiDocument to true, but the SdiDocument property doesn't seem to be around any more.
When this project was originally written (I'm not the original dev) this area was going to have multiple tabs but it has since been decided that there will only ever be one tab and that it can not be closed, so we don't need the "tabs" part of this control.
Honestly, it would probably be better if this was just a panel but it would be a lot of work to make that change so if anyone knows how to do this I would greatly appreciate it!
Currently this is not possible. See this GitHub issue for reference.
Problem seems to be the expected audience of this feature, but PRs are welcome.
I'm starting my first C# project, and I want to make a "form designer" (like the one in VS).
The idea is, there will be a visual form designer with a limited toolbox, which will generate Python code (later more) to create the same form.
Problem is, I have no idea how to even get started. First of all, I have the form designer in VS: how do I make a "form-within-a-form?"
Next... I have no idea how complicated this is going to be. I suppose I could just make little boxes appear beside each control created on the form when it is clicked, for resizing, and make a textbox appear on it when double clicked or something, to change the text in it... Things like this.
So another thing I would like to know is this:
I do have programming experience in C and C++, I've done PHP for a number of years and am starting with Python as of recently. I've generated forms dynamically in VB6. Given this experience, am I in way over my head with this project?
this looks like a really good place to start. It has a pretty good example to get you started. You can even download his source (registration required).
It sounds like you're aware it's non-trivial for a C# first-timer. If you keep it pretty simple, it sounds like you're heading in the right direction (although a web-based form designer might be easier).
SharpDevelop would be an example of a full-featured IDE that can be re-purposed, but that's way over the top.
Good luck!
For most people starting out in C#, this project would be too much. With your VB6 background, you may be able to pull it off, though.
Here's a hint: the Visual Studio Windows Forms designer draws controls on its surface - by asking the controls to draw themselves.
I am trying to create a winForms user control. But I want would like a User control that - when placed on the form -- doesn't take any form space. Instead, it lodges itself nicely below like OpenFileDialog does.
First, what kind of user-created thing is this? Is it still called a "user control"? If not, that may explain why all of my searches are in vain. Secondly, what object do I need to start with to create something like this?
A gentle shove in the right direction would be VERY appreciated.
Thanks.
--Jerry
Controls that appear in the "component tray", like the Windows Forms Timer control, inherit from Component.
To create one with some automatic boilerplate code, right-click on a project and click Add... | Component
I believe you're talking about creating a Component.
Okay... I KNEW that... I feel an inch tall now.
I would love to retract the question and hide my stupidity, but I think I'll leave it up for everyone else who may be asking the same question and just need a gentle reminder, too.
Thanks for the whack on the noggin!!
I'm looking for a free advanced dropdown list control. Basically something that provides a dropdown list which can have icons, and multiple bits of text per entry (preferably one large bit of text and then a smaller bit of text underneath).
Anyone know of such a control? I've had a look but can't seem to find one.
If I can't find it I spose I'll have to create it myself. I've done a bit with custom controls but I'm not really sure how I'd go about this...how would one take a ComboBox or something but make each entry completely graphically customisable?
Any links to controls, or hints on how to create one would be greatly appreciated.
it's not a drop down list, but I think you can use the knowledge here to do the same thing
I haven't found anything on the free side of WinForms that lets you do this. If you have green fields, however, WPF gives you what you're looking for out of the box.
Check out Krypton Toolkit which is free.