|
Of course, my mistake.
So the only problem was the last seek.
I stand corrected.
|
|
|
|
|
Instead of bw.Seek(-10, SeekOrigin.End);
I tried
bw.Seek(10,SeekOrigin.Begin);
and
bw.Seek(("hello World".Length+1)*-1, SeekOrigin.Current);
both worked
|
|
|
|
|
Thankyou both for taking the time to reply =)
|
|
|
|
|
I've been working on a simple little Bible program and would like to get the Word displayed in a newspaper columns. Currently it's loading an entire chapter into a label control but I know that's not ideal.
I thought about placing multiple long label controls on the form but then I'd need a way to determine when to send the text to the next label or if the text goes off page or not. The reason I'm using a label right now is because I can set the background to an image of some old parchment paper.
Well, anyways, if anyone knows of a control out there that does this or a way to do it programmatically then I'd really appreciate it!!
Thanks!
|
|
|
|
|
First you have to get control of the journalist writing the column...
|
|
|
|
|
As I understand it you can get everything you want, and more, with a Panel.
In its Paint handler, you need to draw the background with Graphics.DrawImage(),
then the text with DrawString().
Graphics.DrawString() will wrap text for you if you give it a rectangle of the
intended width and sufficient height; there are about 30 overloads of that method,
so try to find the one that fits you most.
|
|
|
|
|
There is another way to do it as well provided you are willing to embrace .NET 3.0. With WPF there are a few controls which allows you to achieve what you want with great ease.
There is a hands on lab from Microsoft with a working sample to help you through. Try this link to download the hands on lab
http://wpf.netfx3.com/files/folders/labs/entry3343.aspx
Hope this helps
|
|
|
|
|
<br />
public String GiveTxtBxCellValue(GridView gv, Int32 RowNumber, Int32 CellNumber, Int32 ControlNumber)<br />
{<br />
return ((TextBox)gv.Rows[RowNumber].Cells[CellNumber].Controls[ControlNumber]).Text;<br />
}<br />
<br />
public String GiveLabelCellValue(GridView gv, Int32 RowNumber, Int32 CellNumber)<br />
{<br />
return gv.Rows[RowNumber].Cells[CellNummer].Text;<br />
}<br />
If the PK or FK field in the grid is editable it is placed in a Textbox field
In that case you use
String PrimaryKeyField = GiveTxtBxCellValue(YourGrid, YourGrid.EditIndex, PKCellnumber, 0);
mostly 0 control is the control you need.
Same for ForeignKeyField
If the PK and FK are NOn-editable in your GridView you use
String PrimaryKeyField = GiveLabelCellValue(YourGrid, YourGrid.EditIndex, PKCellnumber);
-- modified at 2:23 Friday 3rd August, 2007
|
|
|
|
|
Hi I am using class file to Add Or delete Or update data in my SQl Server DataBase. Now I want to write code under a button click event to show the next row data serially in my text boxes(or may be I can Define them).Now Can any one tell what is the method or command to veiw the next data or next row or previous?
|
|
|
|
|
There's no such method. You'll probably want to load data in a DataSet, maybe wrapped in a class that holds an index to the current DataSet.Tables[0].Rows[ndx] .
|
|
|
|
|
How can I define Tab order in my form? I mean suppose I have 4 textbox and 3 buttons in my form. AnD Now I want to make a Tab order. Can anyone tell me how?
|
|
|
|
|
Hello,
Just set the "TabIndex" Property of the Controls.
All the best,
Martin
|
|
|
|
|
Thank you Sir. And All the best to you too
|
|
|
|
|
You can use Visual Studio to do it graphically. With the form open (and selected), go to View - Tab Order, and then click on every control in the order you want.
|
|
|
|
|
Use the TabIndex property and make sure TabStop is set to true.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello, im a C# newbie and im having trouble with the transition from C.
In particular with using references in place of pointers.
I have a book called Professional C# but it does not seem to cover what I want to know. Namely, I want to assign a reference to a bool value type, such that I can use it to change the value; or so that I can pass the memory location as a parameter to a method, such that the method will be working on the value the reference points to.
My current understanding is that:
<br />
bool symbol = true; <br />
bool pointer; <br />
<br />
pointer = symbol;
Thanks
Rich
|
|
|
|
|
Take a look at "unsafe" code is C#. You have to use the unsafe keyword for the code block, method or class where you manipulate your pointers. Also, the project needs to have the unsafe flag set in the project properties or command line compile.
|
|
|
|
|
Hi,
first of all, be careful, not all replies are correct or even to-the-point
your example does not contain references or pointers; calling a variable "pointer"
does not turn it into a pointer !
The CLR (that is the system underneath several languages including C#)
lets you work with "value types" (such as int and bool, but also struct) and
"reference types" (such as Form and Button).
A local value type (one declared inside a method) is stored on the stack.
If you pass it as a parameter to another method, it gets copied (or at least
behaves as if it were copied), so that method cannot modify your variable.
Things change when you add the "ref" keyword to your parameter list, both
for caller and callee. Now you are really passing a pointer, and the callee
can modify the caller's variable.
If you're familiar with C, it is like adding a * at the caller, and a & at the
callee (but then all the code of the callee needs additional *, not so in C#).
A reference type is different, it IS a pointer to an object, so when you pass it
to some method, that method can do whatever it chooses to do to your object.
Conclusion: if you have bool symbol=true;
and you want to call a method such that it could change symbol, then do:
someMethod(ref symbol);
May I suggest you buy a book on C# and work your way through it.
I am convinced you need to have a reference book at hand at all times when
starting to use a new language.
Good luck!
|
|
|
|
|
Luc,
Most helpful, I do have a book on C# and had come across the ref keyword.
However I was only using it in the member function declaration and not when I invoked it. I think it did not help that i've jumped in at the deep end with my first app - could have chosen something a bit easier, I am learning quite quickly though!
Cheers all Rich.
|
|
|
|
|
You're welcome.
I still recommend you work your way through the book you have, possibly
skipping those specialized chapters that don't interest you yet.
You really must grasp all the implications of value and reference types
before you can do any serious work.
|
|
|
|
|
Well, I thought I did, but obviously not. I've been trying to do run through the book and code the app at the same time. Guess ill hit the book a bit more...
|
|
|
|
|
Try this one,
http://www.csharphelp.com/archives/archive77.html
|
|
|
|
|
Dear Friends,
I have to validate digital signature inside an XML which we receive from our client. Client has given us their cetificate also which contains their public key. I am using following lines of code to verify the signature but I am getting false everytime. Moreover, .Net framework does not tell what went wrong behind giving this false output value. I am using .Net framework 1.1/C#.
<br />
XmlDocument xmlDoc = new XmlDocument();<br />
xmlDoc.PreserveWhitespace = true;<br />
xmlDoc.LoadXml(SamlXML);<br />
bool validSaml = false;<br />
<br />
X509Certificate cert = X509Certificate.CreateFromCertFile(certificateFileName); <br />
XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);<br />
mgr.AddNamespace("saml",this.samlAssertionNameSpaceURI);<br />
mgr.AddNamespace("ds",this.digitalSignatureNameSpaceURI);<br />
XmlNode nodeSignature = rootNode.SelectSingleNode("//saml:Assertion//ds:Signature",mgr);<br />
if(nodeSignature == null)<br />
{<br />
this.errorNumber = Const.SAML_ASSERTION_SIGNATURE_INVALID_NOT_DEFINED;<br />
this.errorMessage = "ds:Signature node is missing";<br />
return validSaml;<br />
} <br />
<br />
SignedXml verifier = new SignedXml(xmlDoc);<br />
verifier.LoadXml((XmlElement)nodeSignature);<br />
<br />
KeyInfo key = new KeyInfo();<br />
key.AddClause(new KeyInfoX509Data(cert));<br />
verifier.KeyInfo = key;<br />
<br />
if(verifier.CheckSignature())<br />
validSaml = true;<br />
else<br />
validSaml = false;<br />
I am getting false everytime when I call CheckSignature() method. Can someone please help me. I would appreciate any type of help in this matter.
Thanks and Regards,
Amit
|
|
|
|
|
Hi
I'm trying to serialize a class. Everything works fine, but I have problems serializing a property which returns one of my custom types. This is the class:
public MultiSampleType MultiSampleType
{
get { return multisampleType; }
set { multisampleType = value; }
}
public bool VSync
{
get { return vsync; }
set { vsync = value; }
}
public Resolution CurrentResolution
{
get { return resolutions[currentResolution]; }
}
Both MultiSampleType and VSync get serialized, but CurrentResolution does not. I have marked my own class Resolution as [Serializable], but it doesn't work. This class also contains some public properties.
Any suggestions?
thanks in advance
/edit:
Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this. Is there a way to achieve this without it?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this
But that doesn't make any sence I guess, you will not be able to DeSerialize it without an setter.
All the best,
Martin
|
|
|
|