|
Hi Rashid,
U should try ASP.NET Configuration. I believe U will get your answer there.
Regard,
Edwin
|
|
|
|
|
I want to be able to write data, to a file in a particular place, and read it back from that location.
The code i have below will write the data to the file with no issues, but i cant figure out how to get it to read it back. Any help is appreciated,
Thanks
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
FileStream fs = new FileStream("test.dat",FileMode.OpenOrCreate,FileAccess.ReadWrite);<br />
BinaryWriter bw = new BinaryWriter(fs);<br />
BinaryReader br = new BinaryReader(fs);<br />
<br />
bw.Seek(10,SeekOrigin.Begin);<br />
bw.Write("hello World");<br />
<br />
bw.Seek(-10, SeekOrigin.End);<br />
<br />
string myString = br.ReadString();<br />
<br />
MessageBox.Show(myString); <br />
}<br />
|
|
|
|
|
Hi,
you have confused yourself I am afraid, I'll annotate your code with
the offset each reader/writer has:
FileStream fs = new FileStream("test.dat",FileMode.OpenOrCreate,FileAccess.ReadWrite);
BinaryWriter bw = new BinaryWriter(fs);
BinaryReader br = new BinaryReader(fs);
bw.Seek(10,SeekOrigin.Begin);
bw.Write("hello World");
bw.Seek(-10, SeekOrigin.End);
string myString = br.ReadString();
In summary: you can attach as many streams as you want to a single file.
Each stream will see the same data, but have its own pointer pointing into that data.
you skipped 10 bytes (in a new file, those bytes remain filled with zeroes),
then write a string, then move somewhat back.
The reading stream has not moved yet, so it reads at position 0, and finds a lot
of zeroes, which results in an empty string.
Normally you don't jump around like that. You either write (or read) sequentially,
or you move purposely around (say to skip records you are not interested in).
Hope this helps.
|
|
|
|
|
There is only one stream, bw and br share it.
|
|
|
|
|
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...
|
|
|
|