|
When you put text in a label doesnt it just get cut off if it doesnt fit anyway?
Or am i just confused about stuff
|
|
|
|
|
It does get cut off, meaning that what it doesn't fit it's not rendered, but the trimming method offers a way of informing the user that the text didn't fit it's area by inserting a "..." string at the end of the visible text.
I hope we understand...because is a rough world out there...
|
|
|
|
|
I kind of resoved the problem in a "manual" way : implementing my own Pain method - work's fine for what i neaded the functionality.
I hope you understand...because is a rough world out there...
|
|
|
|
|
Aww, dammit, worked out this for nothing, well i'll post it anyway, and then well, whatever:
string labeltext = this.label1.Text;<br />
int length = labeltext.Length;<br />
<br />
if(length > 35)<br />
{<br />
labeltext = labeltext.Remove(32, length - 32) + "...";<br />
}<br />
<br />
this.label1.Text = labeltext;
that number there, yeah 35 thats the one, that should be however many characters that fit into your label, and then the second number (32) should be your first number minus 3 so that the "..." fits.
And if you want to keep the original text, just save it as a different string.
Well i'm outa here ##----------------------------->>
|
|
|
|
|
Unless you've replaced the default font with a fixed width one this isn't a good implementation since some characters are wider than others and you maximum char count won't be fixed. The proper way to do this would be via the use of Graphics.MeasureString(...)
|
|
|
|
|
Hello,
I am trying to export a datagrid to excel, I have two basic foreach statements:
<br />
int rowIndex=0;<br />
<br />
<br />
foreach(DataRowView row in dataview) { <br />
rowIndex++; <br />
ColumnIndex=0; <br />
<br />
<br />
foreach(DataColumn col in dataview.Table.Columns) {<br />
ColumnIndex++; <br />
if (ColumnIndex > 3) { <br />
theRange = (Microsoft.Office.Interop.Excel.Range)excel.Cells[rowIndex+1,ColumnIndex-3];<br />
theRange.Font.Name = "Arial";<br />
theRange.Font.Size = 8;<br />
<br />
} <br />
}
}
Any ideas why it is so slow.
Thank you very much.
|
|
|
|
|
It appears to me that your foreach statements are incorrect. You start off looking at each row of the dataview.
<i>foreach(Dataview row in dataview)</i>
Then you loop through each colomn in the davaview
<i>foreach(DataColumn col in dataview.Table.Columns)</i>
/*
* Change this to look at each Column in that row rather
* than the entire table.
*/
Then you move onto next row.
What I see going on here is that your reading each column for every row in the dataview.
|
|
|
|
|
To be more precise, I should change the inner foreach loop which loops through the columns, to something like:
for (int i = 0; i < Columns.Count; i++) {.......};
I guess like that it should b e a bit faster.
Will try it.
Thank you.
|
|
|
|
|
Hi all,
I'll be teaching C# in a school and my audience is quite young(~14-17) so I wanted to ask you what do you think would be the best book I could follow to make them really get into C#? Any suggestions are appreciated.
Regards
|
|
|
|
|
Hi,
I doing an app in winforms. I have groupboxes with few checkboxes or radiobuttons. How do I get the value of selected control from each groupbox.
Thanks.
|
|
|
|
|
The data isn't stored in the groupbox at all. You need to examine the checked property of each control seperately.
|
|
|
|
|
Is it possible to hide any public method or public property of the base class when inheriting that class.
If yes, then how?
Infact I am creating a custom control by inheriting a ScrollableControl and I don't want to show the AutoScroll property to user of my control (developer).
Thanks
-- modified at 12:39 Thursday 10th November, 2005
|
|
|
|
|
|
That's a good short answer there. Direct and to the point!
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Absolutely hiding isn't possible. But there are a few tricks to accomplish what you are trying to do.
Have a look at this snippet:
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool AutoScroll
{
get { return base.AutoScroll; }
set {}
}
- It will disable Intellisense in the designer.
- It will hide it from the properties window.
- It won't allow any changes to this property
Note that if a user of your control types yourClass.AutoScroll = false then the compiler won't give any error... but who said that solution was perfect . But if you also add the Obsolete attribute then intellisense will at least give him a hint.
|
|
|
|
|
Dear Programmers
I want Time TextField Not Like DateTimeField he'll be with this format
for example
hh:mm AM
plz if u help me
|
|
|
|
|
You should use the DateTimePicker control.
Set ShowUpDown to true.
Set Format to Custom.
Set CustomFormat to "hh:mm tt".
|
|
|
|
|
Hi,
I have an app that needs to trap mouse events across a form hosting multiple controls for a keep-alive timer. Any help would be greatly appreciated.
|
|
|
|
|
Write handlers for some or all of the mouse events: MouseDown, MouseUp, MouseEnter, MouseHover, MouseLeave, and MouseMove events, and wire them to *every* control on the form.
|
|
|
|
|
Hi, and thanks for responding. Lets say I write mouse events for Form1; how do I wire them to 'every' control on the form?
this.MouseMove +=new MouseEventHandler(Form1_MouseMove);
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
//Do Something here
}
|
|
|
|
|
rich_wenger wrote: how do I wire them to 'every' control on the form?
this.MouseMove +=new MouseEventHandler(Form1_MouseMove);
btnOK.MouseMove += new MouseEventHandler(Form1_MouseMove);
txtName.MouseMove += new MouseEventHandler(Form1_MouseMove);
chkRemember.MouseMove += new MouseEventHandler(Form1_MouseMove); and so on. Or you could also do this:
foreach(Control ctl in this.Controls)
ctl.MouseMove += new MouseEventHandler(Form1_MouseMove); If you have controls inside other controls (panels or group boxes for example), you'll need to do that recursively. If you always use the same handler, the same routine will be called for events raised by any controls.
I hope this helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
And you can use the following sample code to add mousemove event handler to every control on your form (as Luis pointed out).
<br />
<br />
AttachEventHandler(this);<br />
<br />
void AttachEventHandler(Control ParentControl)<br />
{<br />
foreach (Control ctrl in ParentControl.Controls)<br />
{<br />
if (ctrl.HasChild == true)<br />
{<br />
AttachEventHandler(ctrl);
}<br />
else<br />
{<br />
ctrl.MouseMove += new MouseEventHandler(Form1_MouseMove);<br />
}<br />
}<br />
}
|
|
|
|
|
Thanks, I'll give it a try after lunch.
|
|
|
|
|
Your solution works except for the following statment:
Gulfraz Khan wrote: if (ctrl.HasChild == true)
It should actually read:
if (ctrl.HasChildren == true)
Thanks again.
|
|
|
|
|
Hi there,
i'm searching for a way to create a component from a control designer, and pass some parameters to it.
This create an instance of my object:
<br />
IDesignerHost h = (IDesignerHost)GetService(typeof(IDesignerHost));<br />
MyComponentType myComponent = (MyComponentType )h.CreateComponent(typeof(MyComponentType));<br />
What if i want to pass parameters to it?
Bye.
|
|
|
|