MonthCalendar Control has extra border when ShowToday is False - c#

In Winform's MonthCalendar control I am getting a weird white border on the top and bottom of the calendar when I don't want to show the today label.
Is there anyway to disable this?

I think I see this too. The size of the calendar is calculated by a private method named GetMinReqRect(). It returns a size too large when ShowToday is off. The comment this method has in the Reference Source is:
Used internally to get the minimum size needed to display the MonthCalendar. This is needed because NativeMethods.MCM_GETMINREQRECT returns an incorrect value if showToday is set to false.
Looks to me somebody in the Windows group fixed the bug and forgot to the tell the WF group about it. Unsurprising, the WF group is very hard to find.
I don't see an obvious workaround, the method is private. SetBoundsCore() applies the size, there is no way to bypass it. You can post the bug to connect.microsoft.com but you'll get the "post to a forum to get help" brush-off.

Related

ObjectListView doesn't word-wrap

I am using ObjectListView instead of the standard ListView is because I wanted to word-wrap the columns.
I read in several places that the only thing I need to to in order to enable word-wrapping is the set column.wordWrap to true.
I did just that, but it doesn't work.
What am I missing here?
Edit:
I realise now that I need to make my column owner drawn.
I found this page which sort of tells me what to do, but I'm not sure where to place it in my code. I'm also not quite sure whether I need to add certain attributes inside the delegate to allow word-wrapping (by the looks opf things it's enabled by default). The thing is, I tried what I found in this page, copied it word for word, and my list looks exactly the same...
If you mean by "word wrapping", you want different rows to have different heights, the FAQ answer is correct -- it simply can't be done.
However, if you make each row so that it can display two or more lines of text, then, yes, ObjectListView can word wrap.
It needs three conditions:
Set WordWrap to true on the column to wrap. You've already done that.
Make sure the ObjectListView is owner drawn (set OwnerDraw to true -- this can be done in the Form Designer). The base ListView can't word wrap, so we have to draw the cells ourself.
Make sure there is room to see the wrapped lines by setting the RowHeight to 32 (or some other value)
This is the data tab from the demo. The first column has WordWrap set to true.
On the ObjectListView SourceForge FAQ page, it explicitly states:
Can it word-wrap?
No.

Silverlight C# - Set selection in textbox via code?

I'm working on a spellcheck function for my app, and want to have the word that's currently being looked at highlighted. I'm tracking the char count as I loop through the words in the textbox, so I know where to set the selection at.
I've tried txtArticle.Select(0, 10); just as a test, as well as setting the txtArticle.SelectionStart and txtArticle.SelectionLength properties, but the textbox doesn't show anything highlighted. What's the dealio?
Actual code I've tried:
txtArticle.SelectionStart = charCount;
txtArticle.SelectionLength = checkedWord.Length;
as well as
txtArticle.Select(charCount, checkedWord.Length);
I've positively no idea what I'm doing wrong, unless you can't set what's selected in the TextBox via code, which I just can't imagine is the case. Is there perhaps some extra property that I need to set for the TextBox itself?
Thanks yet again!
-Sootah
Documentation on MSDN of TextBox.SelectionStart Property has an example that works. This states that programmatic text selection is actually supported in Silverlight.
Looks like something else is going wrong in your application. When do you call this code? Try calling it after everything is loaded, and rendered on screen. May be on a click of a button.
If above does not work, create a sample application/page and try to follow MSDN example. When you get it working, try to figure out why it doesn't work in your application.

In Gtk, how do I remove the shadow from a Statusbar?

If I make a Statusbar, and PackEnd a Label to it, it looks something like this:
The Shadow disappears over the Label, but remains over the rest of the Statusbar. I want to remove the Shadow from the entire Statusbar. The PyGTK documentation mentions a property called shadow-type, but it's readonly, and nowhere to be found in GTK#. How do I get rid of this shadow?
You're not supposed to pack stuff into the statusbar, it's not meant as a general container.
To display text in a status bar, use its own API, i.e. gtk_statusbar_push() from C. The GTK# docs on go-mono.com seem to be offline, so I couldn't link to those right now.
shadow-type is a style property, which means it's actually supposed to be set by the user and/or desktop theme. You can set it by writing a custom style file for your application and reading it in using gtk.RcStyle.
If you have a need for two separate status messages in your application, you could also consider packing two status bars into an hbox.
The first child of a GtkStatusbar is a GtkFrame which gives the shadow border (edit: apparently not). You should be able to do this:
statusbar.get_children()[0].set_shadow_type(gtk.SHADOW_NONE)
Several apps (most notably Epiphany and, in the past, Galeon) actually replace the contents of that frame with an HBox so they can add stuff to the statusbar.

How to get width of button in DateTimePicker-Control/Controls in general?

I implemented a custom DateTimePicker. On the DateTimePicker there is a button. In the examples I've found it's width is set to 16. This is working but I would like to have a dynamic approach.
So, is there a way to get the size of this button or is there a general way to get information about .Net-Control sub elements like size etc.?
Trying DateTimePicker.Controls didn't help me (it's empty).
Most all Win32 arrow buttons key off the scroll bar metric:
You want SystemInformation.VerticalScrollBarArrowHeight
Two helpful classes: SystemInformation and ControlPaint. When dealing with custom controls they can be invaluable.
Int32 size = SystemInformation.VerticalScrollBarArrowHeight;
ControlPaint.DrawScrollButton(e.Graphics, 0, 0, size, size, ScrollButton.Down, ButtonState.Normal);
All windows forms controls have a struct assigned to them called "Size" if you refer to the myButton.Size.Width you should be able to modify the size of the button which is an int. Conversely you can do the same with myButton.Size.Height .
The DateTime picker uses the native Windows controls. The "button" you mention is something that is drawn by Windows itself.
In your current OS, there might be something that resembles a button, but in an old or future OS the DateTime picker might be completely different.
Just draw your control the nicest and easiest for the user, and they will be happy.
Can you post the code for the DateTimePicker that you've implemented? It might help illustrate your exact problem. By the sounds of it, the button isn't contained within the DateTimePicker, but on the form adjacent to it. Please correct me if I'm wrong.
So, if you had the following:
DateTimePicker dtp = new DateTimePicker();
Button btn = new Button();
btn.Size.Width = btn.Size.Width * 2;
You can access and re-set the size of the button control.
If the button really is contained within the DateTimePicker, then expose it as a public property (or ideally an internal property), and access it directly via the DTP.

How do I move a tooltip?

I'm using the CellToolTipTextNeeded event of a DataGridView, and the tooltip is being shown under the mouse. I can get the ToolTip object out via reflection, but I don't have any control over where it's positioned since I'm not the one calling Show(). How do I move a tooltip?
How about a custom one?
I think the short answer is: you can't, not yet anyway. I would probably think about building a custom one like 'unknown (yahoo)' suggested.
You'll have to control the tooltip yourself using the Show and Hide methods if you want any control over how and where it is positioned using the 2.0 framework unless you want to get into Window's API calls.
Unfortunately, it looks like the tooltip position is set very, very early on in its creation. The tooltip only has 3 events to handle, and we aren't very interested in Dispose in this case.
The Draw event is fired after the Popup event and it seems as if the position has already been set as the Bounds property in the PopupEventArgs is readonly.
Here's a link to one of many articles (at the time of this post) on creating a custom control:
http://andrusdevelopment.blogspot.com/2007/10/implementing-custom-tooltip-in-c.html
And the MSDN documentation on using the tooltip's Show and Hide methods is actually fairly decent:
http://msdn.microsoft.com/en-us/library/44atyhsa(VS.80,printer).aspx
Sorry, but it just doesn't look like there is a quick and easy answer to this one. Hopefully someone will prove me wrong for both are sakes.
Scott
There is a good answer at this link that uses a Tooltip object.
How to override default tooltip behavior of a C# datagridview to increase the tooltip delay for particular cells

Categories