|
hi,
The code below demonstrates one possible way of doing what you have requested...
Label l1 = new Label();
l1.Text = "Hi there";
l1.Width = richTextBox1.Width;
l1.Location = new Point(0,0);
l1.BackColor = Color.AliceBlue;
Label l2 = new Label();
l2.Width = richTextBox1.Width;
l2.Location = new Point(0,l1.Bottom);
l2.Text = "Howz life";
l2.BackColor = Color.Beige ;
richTextBox1.Controls.Add(l1);
richTextBox1.Controls.Add(l2);
hope this helps you or atleast gives you an idea... this has what occured to me...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Hi,
Thanks for that very good idea.
What I want is also that this textbox should have editing capabilities also
like a notepad.
By doing the way you mentioned in the sample code, we might be able to edit/select only one line at a time.
Thanks & Regards
Mahesh
|
|
|
|
|
The best way to accomplish that, would be a RichtextBox. LokiSD wrote an article[^] on how to do Richtextbox background highlighting in Vb.Net. It would be worth looking into.
What you would need to do, is find out the length of the line, and where the line starts. Set the selectionstart to the linestart, and selectionlength to the linelength. Then, call the function to highlight the selection color.
Hope this gives you some idea's.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Thanks a lot.
That does the work for me.
|
|
|
|
|
Hi!
I am downloading a file from the web (mostly HTML file). Now I want to load the whole file into a string. How can I do this? I need a method that handles all encodings correctly, i.e. at least ANSI, Unicode and UTF-8...
Best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
If you use TextReader it should detect the encoding.
If you're downloading it from the net you can wrap the input stream in StreamReader and then use ReadToEnd method. It has overloaded constructor so that you can specify encoding of your choice.
|
|
|
|
|
Hi!
First thanks for your reply. I tried this:
public static string TextFileToString(string strFilename)<br />
{<br />
string str;<br />
<br />
StreamReader re = File.OpenText(strFilename);<br />
str = re.ReadToEnd();<br />
re.Close();<br />
<br />
return str;<br />
}
This seems to load UTF-8 files very well, but it fails to load Unicode-encoded files (just the first character of the file is loaded)... Using Win98. Any idea?
Best regards and thanks,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
If you're using the HttpWebRequest to request the files, then the HttpWebResponse will contain the encoding.
You can get the encoding by passing HttpWebResponse.ContentEncoding to Encoding.GetEncoding and create a StreamReader using that Encoding and HttpWebResponse.GetResponseStream .
If you read the documentation for the HttpWebResponse.GetResponseStream in the .NET Framework SDK, it even has an example (although they get the Encoding for "utf-8" - just replace that string with myHttpWebResponse.ContentEncoding in regard to the sample code).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Currently I'm using the WebRequest class instead of HttpWebRequest, and WebResponse instead of HttpWebResponse. Is there maybe any way to look if my WebRequest is a HttpWebRequest and if so, somehow convert it? So I can use the header encoding information?
Thanks for your reply and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
If you're making HTTP requests, cast to a HttpWebRequest . The call to WebRequest.Create with an HTTP or HTTPS scheme actually creates an instance of the HttpWebRequest . This use a provider pattern, however, which can only return the base class (bases don't know about their derivatives, only vice-versa).
Look at the example I mentioned and you'll see what to do. You just cast to the necessary class, assuming that the instance created was an instance of that class (like making a request on a file:// scheme and casting to an HttpWebRequest won't work).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I suppose it's because of IntPtr.Zero in line 1
....logically you can't assign IntPtr.Zero as Window - handle parameter.......rather use something like this:
Form frm = new Form();
Graphics g = frm.CreateGraphics();
//...
|
|
|
|
|
You didn't say waht error message you got or what line it was on. But, Graphics.FromHwnd(IntPtr.Zero) will not return a valid Graphics container. You MUST give it a valid hWnd to work on.
[EDIT]
I take it you want to draw these images on the Desktop and not in your form? You might want to get the hWnd of the Desktop by P/Invoking GetDesktopWindow.
[DllImport("user32.dll")]
static extern IntPtr GetDesktopWindow();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi!
I'm having some problems in my code. I want to get values from a datareader to a double[]. I have read the values to an array list, this is my code:
int counter = 0;
ArrayList al = new ArrayList();
while(dtr.Read())
{
object[] values = new object[dtr.FieldCount];
dtr.GetValues(values);
al.Add(values);
counter = counter++;
}
If I write al it returns the correct values, but I can't get theese values in to a double. How can I do this? Is it maybe easier to put the values directly from the datareader to the byte array?
Thanks!
|
|
|
|
|
hi,
your question is not clear. I don't understand what exactly do you want...
Well here are the 2 possibilities that I can think of...
1st Possiblity :
If you require a specific Array of type object from the arraylist then you may use a similar code as below
string[] s = new string[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[] ss = (string[])al[0];
MessageBox.Show( ss[0] );
2nd Possibility :
You require the full arraylist content in an array...in other words the array representation of the arraylist.
Now the complexity is the arraylist elements are arrays
Then the resulting array will be double dimentional...
The code to retrieve the same is :
string[] s = new string[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[][] ss = (string[][])al.ToArray(s.GetType());
MessageBox.Show( ss[0][0] );
Now tips for your code :
DataReader is returning you an object array. After adding that object array to arraylist(like you did) you can get them back by using one of the methods mentioned above(replace string with object).
In the Individual object arrays that you add to the arraylist... if all the values are of type double then you can safely typecast with double array.
In case you are not sure or the object array contains values from different datatype then first obtain the object array by using one of the above methods and then use "Convert.ToDouble()" method to convert the specific array element to double value.Please refer to code below to get a better understanding...
object[] s = new object[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[][] ss = (string[][])al.ToArray(new string[10].GetType());
MessageBox.Show( ss[0][0] );
Hope this helps you... if I have gone into wrong track... then sorry for that...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Hi
I don't think that you understood me correctly, I'll try to explain it better this time. I want to get values from my db (that I have done). There are at the most 100 values, but there can also be less, but they are all in the same formate (numbers). I want to put theese number in to at double array so I can write them out in a graph.
Thanks again!
|
|
|
|
|
If you want to read doubles from a DataReader like a SqlDataReader , then use SqlDataReader.GetDouble (these types of methods are declared on DataReader derivatives). If each field is a double, then continously read through your DataReader like you're doing, but then iterate over the field count and read those doubles into an array. You can either use an ArrayList or use a multi-dimensional or jagged array.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi wizzards and all!
In the MS-Help is allways a blue banner with title.
I'd like to have the same in my html-helpfiles. Is there an example how to do it?
Ariadne
|
|
|
|
|
Right-click and click "View Source". There's your example.
If you want to generate MS-Help like code documentation, then use NDoc[^]. We went to a lot of work to provide help files that work like MSDN (both old an new) and provide other documenters as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
>Right-click and click "View Source". There's your example.
No, there is a link to some 'occult' files.
I look for a snipped, which makes the blue banner.
Thanks
Ariadne
|
|
|
|
|
Trust me - it's in there. How do you think we on the NDoc team got ours to look the same?
It's this block of HTML plus styles defined in the linked stylesheet:
<div id="nsbanner">
<div id="bannerrow1">
<TABLE CLASS="bannerparthead" CELLSPACING=0>
<TR ID="hdr">
<TD CLASS="runninghead" nowrap>.NET Framework Class Library</TD>
<TD CLASS="product" nowrap> </TD>
</TR>
</TABLE>
</div>
<div id="TitleRow">
<H1 class="dtH1"><A NAME="frlrfsystemexceptionclasstopic"></A>Exception Class</H1>
</div></div>
Use the relative path to the CSS file to see the source for that, which is easy enough. The styles to look at are #nsbanner, bannerparthead, runninghead, product, and dtH1.
<div style="width:100%;font-size:2px;margin-bottom:-10px;background-color:#FF9900;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1,StartColorStr=#FFFF9900,EndColorStr=#FFFBEDBB);"> </div>
Microsoft MVP, Visual C#
<a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=46969">My Articles</a>
|
|
|
|
|
Hi all,
I created some drawing objects, which draws image on the screen by itself. I'm using graphics drawing method inside, for example; Graphics.Draw(), Graphics.DrawRectangle() etc.
I want to ask, is it possible to draw them with OR transparency? because sometimes, they can be overlapped.
How can I solve this problem ??
Thank you for your help....
|
|
|
|
|
If I don't make mistake , when you set your Pen or Brush from a Color structure , you can set it with Color.FromArgb method. You have to set its first argument. (alpha)
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Thanks for reply,
I know we can get Pen / Brush with alpha setting, but Graphis.DrawImage() does not contains alpha setting.
g.DrawImage( image, location);
the main problem is when I drawing some image on screen, it can't draw as transparency. Is there a way to set the alpha of Graphics property??
|
|
|
|
|
I think if you first draw your image , then you can draw your other objects like rectangle with this option and use transparency. Search for GDI+ articless in this site, maybe you get better solutions there.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
For Xor drawing, you want to look into Regions[^]. See the Region documentation here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|