|
Thank you Christian.
I will work on it
Elapid For The Win
|
|
|
|
|
How do I obtain the current mouse position?
Thank you
Elapid For The Win
|
|
|
|
|
Use the MouseDown or MouseUp event-handler for the text-box (or other control) for knowing the current mouse location. For example,
private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point mouseDownLocation = new Point(e.X, e.Y);
}
|
|
|
|
|
Hi,
I want to add the line spacing between two text lines. But in MSDN there is only Font.Height attribute which serve as the following,
the first line
|--------------|
Font.Height |____________|}--->line spacing
|the secondline
How to improve the line spacing height? Please help me ?
welspring
hope for help
|
|
|
|
|
|
thanks for your answer! But now I have another question. In a RichTextBox control , I want to use your method to add the absolute line spacing between two lines. I have overrided the Method OnPaint, just like this,
public class MyRichTextBox : RichTextBox
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
e.Graphics.DrawString(
"This is the first line",
myFont,
Brushes.Black,
new PointF(0, 0));
float height = myFont.GetHeight(e.Graphics);
e.Graphics.DrawString(
"This is the second line",
myFont,
Brushes.Black,
new PointF(0, height+x));
}
But i doesn't work, what should I do. Is it right to override the OnPaint function? Please help me .
welspring
hope for help
|
|
|
|
|
|
In fact, the code cited by me works if you want to show text on some form or some other controls. However, in a RichTextBox, it will not work directly because display of text is managed internally. I personally checked the above method to draw the text on the face of a form by overriding the "OnPaint" and by giving "x" different values of say 50 or 100. It worked perfectly alright.
Now coming back to RichTextBox, I may mention that in the MFC days, in VC++ we had the Rich Edit Control classes, including CRichEditView class which in its 2.0 and 3.0 versions exposed a structure called "PARAFORMAT2 Structure", the contents of which can be seen at the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/paraformat2.asp[^]
I am just reproducing the basic structure of this structure for ready reference:
typedef struct _paraformat {
UINT cbSize;
DWORD dwMask;
WORD wNumbering;
WORD wEffects;
LONG dxStartIndent;
LONG dxRightIndent;
LONG dxOffset;
WORD wAlignment;
SHORT cTabCount;
LONG rgxTabs[MAX_TAB_STOPS];
LONG dySpaceBefore;
LONG dySpaceAfter;
LONG dyLineSpacing;
SHORT sStyle;
BYTE bLineSpacingRule;
BYTE bOutlineLevel;
WORD wShadingWeight;
WORD wShadingStyle;
WORD wNumberingStart;
WORD wNumberingStyle;
WORD wNumberingTab;
WORD wBorderSpace;
WORD wBorderWidth;
WORD wBorders;
} PARAFORMAT2;
#define wEffects wReserved
You can notice that one of the members is "dyLineSpacing" which was used in CRichEditView in MFC for changing line spacing as decided by the value of the other member-variable "bLineSpacingRule".
However, it appears that the aforesaid "PARAFORMAT2" is not exposed in the RichTextBox control in the .NET framework, though to be fair, I admit that I did not search its features exhaustively.
One possible solution could be to locate the previous Rich Edit Control's dll (riched20.dll or any later version) on the system and add a reference in your project and then use the said "PARAFORMAT2" structure. Or alternatively, please try to read the detaild literature in MSDN on RichEditBox in .NET if such a functionality is directly made available.
|
|
|
|
|
whether or no, I should thanks of you. From what you have mentioned, I learned much knowledge. Thanks a lot!
welspring
hope for help
|
|
|
|
|
Hi,
i have a problem with setting the active directory of an aplication
For example when the aplication is like in a folder "c:\myprog.exe"; and in the aplication an openfiledialog is opened and a file selected from a folder like "d:\file.txt" after in the code when i try to save a file by giving only filename the file is saved in folder d:\ instead of the folder c:\where the aplication is located and run from.
it there a way to prevent this change of active directory?
|
|
|
|
|
No there isn't.
What you should be doing is not saving files or anything else by using just a filename. You should ALWAYS, and I mean ALWAYS, use full path specifications when working with files.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello all:
I'm relatively new to c# and i would like to know how to populate a listView with data from an access db. The db only has one table. I need to pull out each memberNumber First and Last names and address. These values are included as my column headers in my listView.
If anyone can help me out i would appreciate it.
|
|
|
|
|
Something like this:
using System.Data.OleDb;
.
.
.
void FillList()
{
OleDbConnection conn = new OleDbConnection("connection string"))
OleDbCommand cmd = new OleDbCommand("SELECT * FROM TableName;", conn))
OleDbDataReader rdr = cmd.ExecuteReader();
while(rdr.Read())
{
ListViewItem item = new ListViewItem();
item.Text = ((int) rdr["MemberNumber"]).ToString();
item.SubItems.Add((string) rdr["FirstName"]);
item.SubItems.Add((string) rdr["LastName"]);
listView.Items.Add(item);
}
rdr.Close();
} What you are doing is initializing a data reader with the resultset from the SELECT query. For every record, you add an item to the list view, with the member number on the first column, and then the first name and last name.
I've left out all error checking, such as in case the connection couldn't be openned, or the some of the fields were null. But that's the general idea.
Don't forget to check the docs to learn more.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thanks alot Luis. That was a big help.
I am having some trouble opening the connection string. Im getting a runtime error declaring that it is set to close. Ive tried a bunch of things but cant seem to get it.
If you have any thoughts there id appreciate it. Thanks again.
|
|
|
|
|
Oops, I forgot:
conn.Open(); should go after declaring the connection, before creating the command object.
If you have trouble with the connection string, for an Access database it is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb; . Check here[^] for more information.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I'm performing a conversion of a VB6 app to C#. The VB6 app used CRC32 for hashcode checksum generation for files.
Results generation between CRC32 (C#) vs. CRC32 (VB6) appear to be inconsistent for the same physical file:
VB6 calls: CalculateFile(<file spec string>)
This returns a large negative integer whose hex equivalent is different from the C# result
C# calls:
I tried ComputeHash(FileStream object) and ComputeHash(<byte array>)
(C# results consistent for both methods)
(I suspect probably because in VB6 the decimal number result is converted to hex after CRC does its thing, whereas the C# CRC seems to convert byte-by-byte and returns a hex).
Since this is a conversion with an installed base, we can't have old checksums compared against new results for the same file. Why does "old" CRC return a large negative decimal and "new" CRC return a byte array that converts to hex?
Not being well versed in byte/hex/decimal conversions, anybody know where I might be going wrong?
Thanks in advance.
Phil
|
|
|
|
|
If a number is not unsigned, the first bit represents if it is negative or not. Try converting that number to an unsigned type, and see if they are the same.
Congratulations on moving to C#, by the way Are you doing it by hand ? If .NET will convert VB6 to VB.NET, there are some great VB.NET -> C# converters out there. I will only accept jobs where I'm allowed to move to C#, so I've used it a bit with good success.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi,
Do any of you have a good example of accessing a WebService over SSL.
I have done most of the research, it keeps failing saying it as
-------------------
The request failed with HTTP status 403: Forbidden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The request failed with HTTP status 403: Forbidden.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The request failed with HTTP status 403: Forbidden.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1296
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +218
testapp.helloworld.Service1.HelloWorld()
testapp.WebForm1.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
---
I have installed the client certificate on my client browser and adding this certificate into ClientCertificates collection before calling the WebService.
We are using Entrust Certificate.
Thanks in advance.
Regards,
Anand Chida
|
|
|
|
|
if your IIS server has a good certificate installed, there is no purpouse to set the certificate client side.
But should work as it works non https too
|
|
|
|
|
Tell me how many would be willing to buy a product for 10$.
Here is the Link ... www.speechtoolscenter.com
There are no links for buying yet. i hope they will add a link soon.
this product reads( word,text,html) file, user can record their own commands.
and much more...
|
|
|
|
|
I wouldn't buy a damn thing from someone who is too cheap to buy advertising space!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to know a question from you that i want to apply a timer between my code. you help me please.
means that for example i have two lines of code let say.
console.writeline("hello1);
console.writeline("hello2);
Now i wana to do that after 10 seconds console.writeline("hello2) executes(not every 10 sec).
console.writeline("hello1);;
//timer of 10 sec//
console.writeline("hello2);
Means that when console.writeline("hello1) then after 10 sec console.writeline("hello2) should be executed..
Please help me ,, i m very near to my destiny.
with regards
Ishtiaq Ahmed
|
|
|
|
|
<br />
maybe this will help<br />
<br />
console.writeline("hello1);<br />
System.Timers.Timer t1 = new System.Timers.Timer();<br />
t1.Interval = 10000;<br />
t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1);<br />
t1.AutoReset = true;<br />
t1.Enabled = true;
and define the ont1 event handler:
public static void ont1(object sender, System.Timers.ElapsedEventArgs e)<br />
{<br />
console.writeline("hello2);<br />
}
there are no facts, only interpretations
|
|
|
|
|
sit this i have checked..its hapeening every 10 sec.but i need to do is that it should be executed 1ce after 10 sec.
i.e
eg when i cliked on button which have two message box,then after first messagebox ,second messagebox appears after 10 sec....in this case
t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1);
if i remove '+' then it can be possible but it cant.
so i need to execute like this way
|
|
|
|
|
Im sorry to say this, but your problem might be that you dont understand how the timer works, maybe due to some problems with the English language.
You should start looking up words you dont understand (like Timer.Enabled) instead of simply hacking in the lines.
ENABLED is used to activate or deactivate the timer, though most of the time Stop() and Start() are the better choices.
If you disable the timer (i.e. Timer.Stop() ) after the first elapsed-event, the timer will not "tick" again.
Cheers
Sid
|
|
|
|