|
dnh wrote:
why not to use Serialization[^]? I belive that you can set (with attibutes) what should be serialized into XML and what shouldn't. However I don't know how it would fit into backward compatibility concept.
Yeah, I had thought about adding a Serializable attribute to the classes, but I don't want every property serialized (especially those from base classes which I can't modify.) Also, for example, I have a Font object, and I want only to save font family, size, not all of it.
Thanks,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
First I would like to thank you for taking your time to read my questions... I really need some helps here.
Bascially I want to write a program in which users can design their layouts.
So let us say I got a textbox, and I want it be to able to be dragged around the main window or resize it... and i want to have like a rectangle box around it when I click on it..
How am I going to start?
I tried using the events mouseUp, mouseDown to move the objects.. but I cant find out how to draw a rectangle around the textbox or how to resize it..
could you please help me out? Thank you so much.
Elapid For The Win
|
|
|
|
|
Ooops - I thought I was in C++ land for a moment....
Your form has a paint event, override it to do any drawing you might want to do on the screen.
Controls have a Location and a Size property. You need to change those to move or resize the controls.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
how do i draw a rectangle thinige around the textbox? you know like in Visual Studio, when you click on an object, there are like 6 small squares at the corners of an object which then let you resize that object..
Elapid For The Win
|
|
|
|
|
Like I said, in OnPaint. You need to draw outside the bounds of the control, so the control can't draw it. You need to create hotspots, and store them in an array. Use them to draw the little boxes, and also to check when someone clicks if they are inside one.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
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...
|
|
|
|