User control that will internally calculate how much text to show - user-controls

I want to develop an user control using Windows.Forms.Label that will internally calculate how much text to show based on the current height and length of the control.
Does anybody have the solution for it.
Thanks in advance.

The simple solution would be to put a Label on your UserControl, and set it to Dock to fill. Set the label's Autosize to false.
If you want to go a step further and an ellipsis to your label, you'll need to look into Graphics.MeasureString.

Related

How to reduce the length of the databand in stimulsoft

I'm a very beginner of stimulsoft. I'm creating a report from my DB SQL but I've got problems with the lenght of the databand.
Basically, I would like to reduce the lenght of the databand because the data-source is different.
In the picture, I would like to trim the databand before the title "Descrizione". Can anyone help me?
Thank you so much
The bands have the heights only and it fills the whole width of its contained (here it is the page).
You need to use the Dock Style property that allows changing the position of the text components dynamically.
But you should check the order of the text components in the Report Tree.

Missing Properties in VBA [duplicate]

I'd like to add a horizontal scrollbar to a VBA ListBox.
It appears that the built in ListBox does not add a horizontal scrollbar automatically. I have a number of fields whose contents exceed the width of the ListBox and are thus unreadable to the user.
I found this article, however the code fails, due to accessing hwnd of the ListBox (which is apparently not available in VBA). I'd rather not write a native DLL to accomplish this as I suspect there is a better way.
Any idea on how I can add a horizontal scrollbar to a VBA ListBox?
I'm open to the idea of using an alternate control rather than getting it to work with the ListBox specifically.
Did you try ColumnWidths property?
I have listbox with horizontal scroll bar. I just had to add ColumnWidths property.
For example I have
me.Listbox1.Columnwidts ="0.5 in;0.2 in;1.5 in;0.75 in;0.5 in"
Unless I'm missing something, a VBA listbox will automatically gain a horizontal scrollbar if the total of its ColumnWidths property exceeds its own width.
There are no properties I know of that affect this behaviour, i.e. I don't otherwise know how to force or disable display of the horizontal scrollbar.
Access will automatically add a horizontal scrollbar if the column width exceed the width of the listbox. HOWEVER, if you are using multiple columns, the first column cannot be set to 0. You must have at least some value in there, even if it's just 0.1" Hope this helps.
In that article, the only reason it's getting ScaleMode is to set the width of the horizontal scroll bar. You don't have to do that.
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, 800, 0
where 800 is the pixel width you want the list box to be able to scroll right to.
You will still need the hWnd. Best bet there is to use an external DLL (written in VB) which can enum through child windows of your process until it finds the windows class for the listbox (you will need to find some way to uniquely identify its parent, such as the window title/text or something). That same DLL could also do the SendMessage call above to set the horizontal text extent (perhaps also it could measure the width of the contained list items).
Handle to he list box can be obtained as follows :-
Dim ListHwnd As Integer
lstboxName.SetFocus
ListHwnd = GetFocus()
Use this ListHwnd as the first parameter to the sendmessage function...
We need to provide the declaration below,Since GetFocus function is not present in VBA by default
Private Declare Function GetFocus Lib "user32" () As Integer
In Visual Studio 2017, you can click on the list box, then go to the properties panel, and then (scroll down to) find the 'HorizontailScrollbar' property. By default this is property is set to false, so you should set it to true.
You know you have set the scroll bar properly when a small triangle appears in the top right corner of the list box.
Hope this helps.

Excel - how to hide value in a chart's datalebel

I have embedded an image to a chart's datalabel. I want to only keep the image and not the value which appears on top of the image.
However I'm not sure how i can get rid of the value to only show the image?
I thought could've set the font colour to transparent but that's not available. I also played around with the number formatter but had no luck?
I'm using Windows/Excel 2010
Thanks
Clicking on one of the data labels once will select all of them, clicking a second time will select only the one you clicked on. Then just hit the delete button. (You should also be able to edit the font/colour in the Home tab.)

datagridview layout behaviour

I have c#/2008/winform application.
I have a form with a picture banner, and a datagridview below it
I want the picture banner to remain fixed in size, and the datagridview to rezise
and fill the rest of the form.
I have set the picturebox to dock=top
(Also pos=0,0, sizemode=centerimage - but these setting are not the problem)
My datagridview misbehaves no matter what i do
If i do dock=fill, it starts from the top of form, and is obstructed by the picture
If i try to set dock=bottom it does not resize with the container
I am aware of the concept of layoutmanagers but this is just a quick app
so i hope i dont need one here.
Any ideas ?
thank you
There may be a better workaround but the first thing I found that worked was to introduce a panel control.
Make you picture box Dock=Top, then place the panel below it with Dock=Fill, then your DataGridView goes inside the panel with Dock = Fill.

how to add a textBox and a TextField to a form in j2me

i want to display both TextBox and TextField on the screen at a time but i am unable to add TextBox to form. is there any way to display both of them at a time. that is textBox at the top and TextField below it. plz help me. i will be pleased if any code is given
thank u in advance
A TextBox is a Screen, not an Item, therefore you cannot add it to a Form, and there is no way to display both of these things on screen at once.
If you want to display some additional text on screen while a TextBox is active, you can use its title (via setTitle()), or you could scroll it across the top using setTicker().
I guess, you must write you own TextBox component. It must extend Canvas. And you must paint it yourself, using drawLine, drawString.

Resources