|
Hi!
you can try to override the OnPaint and use the DrawString method of the graphics parameter to redraw the text on your label.
hope that helps!
|
|
|
|
|
If you only need a single line of text/label, you can reduce them to minimum height.
|
|
|
|
|
This was good enough... Changing the TextAlign property to TopLeft and setting the height small enough to not show the next line worked for what I need it for.
Using text boxes just doesn't work and look the same as using labels. And I don't have the time to create my own custom controls right now.
Thanks
Brent
|
|
|
|
|
public class NewMonitorDetails<br />
{<br />
<br />
public static int MonNumber;<br />
public static string EDID_Info; <br />
<br />
public NewMonitorDetails(){}<br />
}
I have the above class...I want to create an array of the above class to store different values in MonNumber and EDID_Info, so that I can access those values in other calsses where ever I want.
How do I do this. Thanks.
|
|
|
|
|
Manu_81 wrote: I want to create an array of the above class to store different values in MonNumber and EDID_Info, so that I can access those values in other calsses where ever I want
First, if you declare the fields as static you will only get one for all instances of the class. So, if you want to create multiple instances of the class you cannot create these as static for the purpose you want.
Second, declaring a field as public is bad form. You should declare them as private or protected and access them through properties. Read this article if you want to know why you should make the fields private and access them through a public property[^]
Finally, you can make the array global by adding it as a static field to the class (because you only want one instance of the array made available globally across your application (right?)
So your class will look something like this:
public class NewMonitorDetails
{
private static ArrayList newMonitorDetailsArray = new ArrayList();
private int monNumber;
private string edid_Info;
public NewMonitorDetails()
{
}
public int MonNumber
{
get { return this.monNumber; }
set { this.monNumber = value; }
}
public string EDID_Info
{
get { return this.edid_Info; }
set { this.edid_Info = value; }
}
public static ArrayList NewMonitorDetailsArray
{
get { return NewMonitorDetails.newMonitorDetailsArray; }
}
}
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
-- modified at 4:19 Tuesday 24th January, 2006
|
|
|
|
|
Thanks a lot for your reply Colin. Its really helpful as I am new to obj. oriented...
Got what you r saying.
Now how do I set and retrieve values to this class.
What I am doing exactly is I get the Monitor number and EDID info for each active Monitors connected from dll. So I want store this pair of values for each monitors in some global data structure so that I can use it where ever I want in my app...
Thanks again.
|
|
|
|
|
Manu_81 wrote: Now how do I set and retrieve values to this class.
Through the properties. In C# this looks just the same as getting and setting the field (although the compiled MSIL is different, but you don't need to worry about that). For example:
myMonitor.MonNumber = 2;
myMonitor.EDID_Info = "Some Info";
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Also, I just double checked the code. The NewMonitorDetailsArray property should have been static - so I've corrected that (see updated previous post)
You can access the ArrayList of all NewMonitorDetails by using
NewMonitorDetails.NewMonitorDetailsArray
You cannot set this as it is controlled by the class. But you can perform any methods on the ArrayList (like Add ) so you can modify the contents of the array.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
If you wan't to store any data in the objects, you have to have any non-static members. If you create an object from that class, the object will contain no data what so ever.
If you create an array, you can access it from where ever you like, as long as you have a reference to it. How to best handle that reference is hard to say, as you have given so very little information on what you are trying to accomplish.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a data source that has the the following method.
.Rows.Add(object[] obj}
How do I pass directly to it an array of parameters within parenthesis? Like the following
...Rows.Add(1, "Hello", "World", 18); or
...Rows.Add("1", "Hello", "World", "18"); or
...Rows.Add({"1", "Hello", "World", "18"});
I get errors like ...Rows.Add() does not take n parameters where n is equal to the number of values I put in. The last one gives me errors about the {} being all wrong.
If I create the following:
object[] obj = {1, "Hello", "World", 18};
...Rows.Add(obj);
Everything works fine.
Cheers,
Clint
|
|
|
|
|
Clint,
Try this Rows.Add( new object[] { 1, "Hello", "World", 18 } ) .
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thanks!
That did the trick.
Cheers,
Clint
|
|
|
|
|
Hello,
I had a little question, i made a chat textbox, people can send messages to eachother, the only problem i have is that the scrollbar needs to stay down... after a new message it always goes to the top. I really can't find the method to do that.
I posted a image with the problem.
http://www.theoc.nl/problem.jpg
Thnx in advance
Wouter
|
|
|
|
|
hi!
are you setting the Text property of your textbox?
if that's the case maybe the cursor or the SelectionStart property of the textbox resets to 0 or to the beginning.
try to set the SelectionStart to the end after setting the text.
hope that helps!
|
|
|
|
|
thnx for your reply, let me test
|
|
|
|
|
tb_Player_Messages.Text += _Message + "\r\n";
tb_Player_Messages.SelectionStart = tb_Player_Messages.Lines.Length;
Doesnt really work
|
|
|
|
|
are you having some event from the other controls before setting the text?
like for example, you have to click a button to append the text on your textbox?
if so, sorry but i forgot to tell you that you must call the Focus method of the textbox before setting the selectionstart.
because the focus is on the other control that's why it doesn't show the cursor on your textbox.
and also, instead of "tb_Player_Messages.Lines.Length" use "tb_Player_Messages.Text.Length".
<br />
tb_Player_Messages.Text += _Message + "\r\n";<br />
tb_Player_Messages.Focus();<br />
tb_Player_Messages.SelectionStart = tb_Player_Messages.Text.Length;<br />
i tried it and it works fine.
hope that solves your problem.
|
|
|
|
|
HI,
I have an animation flash file with .fla extension. I want to paly it in one of my form. How do I add it to my form.
Thanks.
|
|
|
|
|
I guees you can put Browser Control on your form ,then display in the control your flash file.
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
That worked !!!
Thanks a lot
|
|
|
|
|
Alternatively you could drop a Flash Player on your form. This might give you more control over playing of the movie and the ability to handle events from the control in your .NET code.
(Add it to the toolbar in VS by selecting it from the COM component list.)
|
|
|
|
|
Hi all,
I am wondering if it is really possible to get the selected text from the Embedded webbrowser control in C# application. It would be a great help.
Thanks and regards
Emran
|
|
|
|
|
This code snippet shows selected text in MessageBox.Don't forget to add reference to Microsoft.mshtml
<br />
IHTMLDocument2 HtmlDoc = (IHTMLDocument2)axWebBrowser1.Document;<br />
IHTMLSelectionObject selection = HtmlDoc.selection;<br />
IHTMLTxtRange range = (IHTMLTxtRange)selection.createRange();<br />
MessageBox.Show(range.text);<br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi Tarsan,
I extremely appreciate your help.
I was trying to follow your tips but I faced two problem,
1] I am using Visual C# 2005 Express (.Net 2) and I dont see the DLL microsoft.mshtml is available for adding. I searched for this dll in google and i did not find it anywhere for download. So, if you have that, can you post that file here ?
2] Second question, I am using the control, "WebBrowser" (.NET 2005 Express edition comes with it), not the "Microsoft Web Browser". So, will your code work for this WebBrowser Control ?
Thanks and regards.
Emran
|
|
|
|
|
Hi Emran.
1) Yo can easy find microsoft.mshtml . Select "Add Reference" in "Solution Explorer" .Add component named "Microsoft Html Object Library" from "COM" tab. The DLL(COM) comes with IE and should be on your computer .
2)Yes, but with small changes and you still need microsoft.mshtml
<br />
IHTMLDocument2 HtmlDoc = (IHTMLDocument2)webBrowser1.Document.DomDocument;<br />
IHTMLSelectionObject selection = HtmlDoc.selection;<br />
IHTMLTxtRange range = (IHTMLTxtRange)selection.createRange();<br />
MessageBox.Show(range.text);<br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|