|
Yeah, that's where it looks like I need to head. I've gone so far as to disassemble the TextBox code to see if I could bypass anything there. It looks like it wouldn't be too much trouble to derive a class from TextBox that would let me at least read the text directly, but I don't see any way to get around the need to create a new string and put it into the textbox. With a 5,000-line buffer, making a copy of the entire textbox even once every time I want to update the contents seems very very inefficient. It's just a shame that I have to rewrite so much functionality. I'm still suprised that I can't find anything else out there that does this, it makes me wonder what I'm missing...
I thought about the ListView as well.. but cut-and-paste becomes difficult to do there, since I wnat to be able to cut-and-paste like a normal textbox.
Thanks for the thoughts! If I do end up with something usable I'll definately post it here!
|
|
|
|
|
My solution didn't include deriving from a TextBox but writing your own drawing code. But if you need text selection, and copy/paste support, definitely derive from a TextBox .
I don't know if the TextBox makes a copy of the string you use to set its Text property, or just keeps a reference (I'd think it makes a copy). To automatically scroll the text box to the end, set the cursor position at the very end, and done )I don't remember the exact properties). And for the bottomless buffer, you'll still have to make a circular queue as I described in my other post.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
i have 2 combobox's in my datagrid i created 2 class's one for combobox "ID", combobox "name"
each one is sorted "Ascending" so the indexing is not matching.
to solve this problem is to write a query to database and get the matching seleted ID and vise versa.
coz i created a class for combobox, how can i write a code to pass the selected item from class ID to myform, or ............
can i override events of combobox class from myForm !!!!!
i used combobox class from this site
http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx
thx
|
|
|
|
|
You can (in youe clas of ID)
write this : in the class level
private string SelItem;<br />
public string SelItemPro<br />
{<br />
get{return this.SelItem;}<br />
<br />
}
and then in the event of the item changed
private void ItemChanged_cb1(object sender,EventArgs ...)<br />
{<br />
this.SelItem = combobox.selectitem.ToString();<br />
}
and therfore as it is a public member u can acces it from your Form from the properties of the combo box
ByMindOnlyYouCanDoIt
|
|
|
|
|
Hi,
I got a quick question : Is there any way to store Maximimze/Minimize Size and Location of form in Registry?
So upon restart - it would read those values from registry and return to its former state
thanx in advance
|
|
|
|
|
why would you do this, in the application it self you can set the size properties and then in each restart of the application it will be at the same size of that you choosed
and also you can set it to sonstant size and set the FormBorderStyle property
to FixedSingle or Fixed3D to make no one has the ablity to change the size
while also when doing this you can make him has the ability to MAXIMIZE to the screen coordinates only
ByMindOnlyYouCanDoIt
|
|
|
|
|
Check the Registry class.
|
|
|
|
|
As it was suggested, check the Registry class.
Just take into account that you have to store the restored position, as well as the state (maximized, minimized or restore.)
You have to save the restored position before the window is minimized or maximized, because when minimized it is moved off-screen. You can do this in the SizeChanging event.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Lets say that I want to send a jpg from one computer to another. The only way I've found to send files is to convert the data into a byte and then send it across a socket; however, when the file has data that can not be handled within a byte, the new file is corrupted.
So, how do you send a file to another computer if the file contains data outside of a byte?
|
|
|
|
|
What do you mean "not compatible with a byte"? When you convert the file (jpeg or other), you should be converting it to a byte array (byte[], not byte) using some form of serialization such as binary serialization (see BinaryFormatter class), then (most likely) writing the resulting byte array to a stream.
I've had no trouble serializing files and storing the resulting byte arrays in databases, transferring over sockets, etc.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thanks for the tip. I'm working on serialization right now.
|
|
|
|
|
Yay. I just made a file go from serialization to byte[] form. Thank you so much, bro.
|
|
|
|
|
Heyas all,
I was hoping someone could give me a hand with a problem.
I have an external file that holds location information on a user defined amount of places (the user can add or remove locations that can be chosen from.) I was making the file format like so:
-name;address;cross_streets;last_visited
What I need to do is to randomly choose a location on an event. The information would then be shown in a read only textEdit but formatted differently with each attribute (name, address, etc.) being on it's own line.
So I was thinking that on program start to load each line of the file into some sort of collection.
Could anyone give me any clues or a push on how to go about doing something like this? Is there an easier way than to load it into a collection? Am I way off in my design?
Thanks,
John
|
|
|
|
|
There are many ways you could go about this, and no way to cover all the bases in a practical reply.
If you're not tied to the existing file format, you might consider using XML. If you're not tied to using the file system, you might consider using a database, etc.
Assuming you want to stick with the current system, then you should probably use a FileStream and some flavor of StreamReader to read individual lines from the file (assuming logical records are separated by Newline characters), then you could use the String.Split(char) method to get a string array of the elements on each line, and go from there.
A couple of the benefits of using XML are flexibility and readability. You'd potentially have a little easier time changing the data you're storing, allowing for nulls or empty values or whatever.
You might also want to consider creating a structure or a class to hold the individual data elements that comprise a location (name, address etc.) - you'll probably want a class as the size of your type is likely to exceed 16 bytes (best practices limit on struct sizes since they're allocated on the stack), and you may also choose to investigate implementing your own custom collection of location objects (see CollectionBase for ideas).
Hope this is sufficient to get you started.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
hi,
how can i design my own window with c#? i want to change the look of the window, the functionality should be the same like a regular window. does anyone know how to do this or a helpful link?
thanks for help
|
|
|
|
|
You can use a graphics path to make irregularly shaped forms. You can turn off the control boxes (minimize, maximize, close), and set your form's background to be an image or a different color, or partially transparent, and so on. Is that what you're looking for?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
You can make the formBorderStyle to None to do your own close and minimize btns and also make the form shaped by the this.Region = new Region(your graphics path);
ByMindOnlyYouCanDoIt
|
|
|
|
|
Hello all
I was under the impression that if I make a call into a static function which uses the value of a static class variable, if I recall the function later the value of the static class variable would reset back to the default coded value.
Now as the following example prooves I am obviously wrong.
I have a test application/dll that has the following code :
StaticLib.dll
using System;
namespace StaticLib
{
public class MyStaticLib
{
private static int val = 0;
public static int GetNumber()
{
return val++;
}
}
}
Console Application (which references StaticLib.dll)
using System;
using StaticLib;
using System.Threading;
namespace StaticTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
while(true)
{
Console.WriteLine(MyStaticLib.GetNumber());
Thread.Sleep(1000);
}
}
}
}
When I ran this for the first time I expected to get the following output
0
0
0
0
0
0
But I actually get
1
2
3
4
5
6
7
Could anybody explain why this is?
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
MrEyes wrote:
I recall the function later the value of the static class variable would reset back to the default coded value.
That is not correct. The value will not reset unless you have code to explicitly reset it.
MrEyes wrote:
Could anybody explain why this is?
That is the correct behaviour. A static is a value that exists for all instances of the class. If some code modifies it then all instances of the class (and any static methods/properties) see the modification.
Some people think of a static that is a global value within the class.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
This behavious is correct. Static variable has lifetime of global variable but it has a scope of local variable. Hence the value of static variable persists across multiple calls to the function.
Unlike nonstatic members where each instance of object has its own copy of variables, the static variable is shared across all instances i.e. only one copy od static variable is available across all instances of objects.
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Hi,
I want to locate the listViewItem when the mouse is dragged over the
listViewItems in a listView. I try to locate which listViewItem is dragged over by the mouse by using the listView.getItemAt(e.X,e.Y) in the dragOver handler, but it can't return the listViewItem located by the mouse(it can return the right x, y of the mouse location)?
Why ?
Many thanks
|
|
|
|
|
Because the GetItemAt method looks at a coordinate local to the control, not the screen (i.e. Point(0, 0) to the control is the upper left corner of the list view, whereas Point(0, 0) to the cursor is the upper left corner of the screen).
Here's some example code that should work for you:
Point localCoordinate = listView.PointToClient(MousePosition);
listView.GetItemAt(localCoordinate.X, localCoordinate.Y);
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
I have a routine which reads a header record from a file, that header record tells how many subsequent records to read, each record having another header which says how long that record is in bytes.
Is it more efficient to allocate an array of (say) 10,000 bytes at the beginning of the loop which process the records then use:
BinaryReader.Read(buffer,0,reclength);
or is it better to just allocate the bytes required on the fly:
byte[] buffer = BinaryReader.ReadBytes(recLength);
For this example the recLength will never exceed 10,000 but could be anything between 1 and 10,000 - the loop can require between 40 and 200 iterations.
|
|
|
|
|
Especially since this is C#, I would code whichever method is easiest for you and then only worry about it if there is an actual performance problem.
When you get to that point, creating one large buffer will typically go on the large object heap and requires more memory at one time, which might be faster on a single user system with few memory constraints.
Your second approach will use more memory during processing, however it will give the garbage collector a chance to collect already processed buffers.
A third approach is to use the stream directly, one pre-allocated buffer and read the data from the stream into the buffer without any allocations in your loop. This is more difficult especially if the records are not fixed size, but will typically perform the best of all the options since there is no allocation in the loop.
However, your loop needs to be driving an efficient processing operation for optimizing reading to make sense. If you are just creating an array of record objects in your loop for example, these changes won't make much of a difference.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|