|
anyone knows about auto scrolling a text box. eg:using a for loop i add values upto 100 to text box,but it only displays upto 10,means even though the scroll is set , i have to scroll down to see the values, what i want is to automatically scroll while values are adding to text box.
|
|
|
|
|
use ListBox and change the SelectedIndex/SelectedValue property every time you add some record
|
|
|
|
|
Hi, call the following in the event where u want auto scroll...
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
For example create one textbox n one button in a form and call the above in the button_click event which adds sum text as well as scrolls the textbox..
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + " Hi this is a test message";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
////textBox1.Refresh();
}
I think u got the answer for ur question...
Regards
Mahesh
modified on Tuesday, March 3, 2009 2:23 AM
|
|
|
|
|
hi,
I have a question about RE.
Lets say I have this string:
<option value="\"108|comment|11f42da7\"">Text</option>
I get the "Text" by using this RE:
MatchCollection m = Regex.Matches(wynik,@"\"">\s*(.+?)\s*");
I use MatchCollection beacuse I do it on a bigger file but for the ease of writing ths post I'm just an example of one line.
Then on my collection I do a foreach and each Text is set as an Item Label in a dropDown list.
But in the m regex I would also like to get the "comment" so then in my foreach loop I would be also able to assign it to the items Tag lets say.
How can I achive this?
|
|
|
|
|
I recommend using an XmlDocument for working with XML.
|
|
|
|
|
but it's not a xml document and XmlDocument in that case sometimes doesn't do its job good so thats why I want to use reg. ex.
|
|
|
|
|
As our team will immgrating from C++ to C#, could you help me to figure out which one is best suit for this scenario.
I think a brief, short enough and cover the most useful part of the language is better.
|
|
|
|
|
Well, you're a little late to the party....
I think the main thing your team needs to understand, is all the ways C# looks like C++ but is not. The main one is garbage collection, and the lack of deterministic destruction. I'd look for a book that aims for these things, that is written for C++ devs, even if it's an older book. These things have not changed.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks for your reply.
Definitely! We should avoid the misused of such feature.
|
|
|
|
|
It's a real trap, expecting basic C++ stuff to work, because it looks the same.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i Will suggest the book "Applied .Net framework proggramming" written by jeffrey richter. Concept that a pure VC++ programmer should understand is about the "Type and object" fundamentals in .Net world. It's structure and how it is handled.. it is bviously a managed one and governed by CLR. And as Christian Graus said you should go through the Garbage collection fundamentals. GC normaly runs as a low priority thread. You should also keep an eye on safe and unsafe concepts.. which you will surely comethrough when you are reading GC ...
|
|
|
|
|
I use image list.in very frist time i can load images.but when i load imaegs into second time in same run time my first images are not show anymore & show second images.... how can i load images countinusly is same runtime....
private void import(object sender, EventArgs e)
{
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(100, 80);
imageList.ColorDepth = ColorDepth.Depth32Bit;
int i = 0;
string[] files = dlg.FileNames;
string[] pathes = new string[files.Length];
foreach (string file in files)
{
pathes[i] = file;
i++;
}
foreach (string path in pathes)
{
FileInfo fileInfo = new FileInfo(path);
String strDir = fileInfo.Name;
listView1.Items.Add(strDir);
imageList.Images.Add(Bitmap.FromFile(path));
}
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList;
}
A S E L A
|
|
|
|
|
Hi,
still at it?
your message isn't entirely clear to me, here is my best shot:
Image files loaded by FromFile() get locked, so maybe a second FromFile() to the same file failes, I don't know. To avoid the lock, do one of these:
1. don't use FromFile(), use FromStream() instead, so first open the stream, then load.
2. use FromFile() to create a temporary image, make a copy, and dispose of the first image, as in:
Bitmap bm1=Bitmap.FromFile("filespec");
Bitmap bm2=new Bitmap(bm1);
bm1.Dispose();
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
ya still in same problem.....its creating more and more problems to me...
then in second time i need to show first and second both time images.....so is it bml1+ bml2 ???
so if i load thired time also?? it can be so many times load....
some think like stack...but i cannot use stack bcz when i need to do drag drop how can i remove the item "remove at".....
A S E L A
|
|
|
|
|
Hi,
1.
I don't know whether you have a file lock problem; if you have, do as I suggested.
2.
You should not remove images from a collection such as an ImageList, since that shifts some of them in the collection, modifying all the higher indices.
3.
If you are afraid the same image might be loaded several times (taking time and memory),
then create an image cache, e.g. use a Dictionary< string, Image> that holds the image together with its filename. Then loading an image becomes a two-step thing:
A) look in cache using myDictionary[filename], if not null use it; else
B) load the image and store it in myDictionary[filename], then use it.
4.
If you don't permanently need the images themselves, say you only need thumbnails, then of course there is no need to keep the images, just keep the thumbnails, hence:
A) look in cache using myDictionary[filename], if not null use it; else
B) load the image, make the thumbnail and store it in myDictionary[filename], then use it.
5.
stacks are useless in this.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:04 AM
|
|
|
|
|
Hi as i know there is not file lock problem...
i thought to do the first type....bcz over here this imageList is in side a listView as LargeImageList...so trying to do is
1- check whether listView.Item.Count == 0
if it is i just load images as useual...
2 else
i creat another image list and copy the first imagelist images in to that new imageList2 by using listView1.LargeImageList.Images copyTo by using ForEach loop...
after that i load new images in to NewImageList imageList2....so my new Images and previeous images will be in Same List.
then i load that image list into listView as LargeImageList....
is this way got anything wrong....??????
A S E L A
|
|
|
|
|
Hi,
I can't answer that, it is still a complete mistery what you want to get done.
For example:
1. how many ListViews are there?
2. how many images are there? (10, 100, 1000, or 10000)?
3. how large are those images (10*10, 30*30, 100*100, 300*300, 1000*1000)?
4. why do you think you should ever remove images from image lists?
and what is your app about?
And then: what exactly is going wrong?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:04 AM
|
|
|
|
|
hehee sorry i forgot to tellu all those....
ill brief u about what im tring to do...
i got two listViewBoxes(BOX A, BOX B)....both listView Boxes i got imagelists....
First user have to Load thier images in to this BOX A...once they load its shows like thumbnail type but actualy happening is doing small size drawing...
mean i load original picture into that (100, 80) size imageBox. i do this bcz later i need to save these images as what they was, in another directory...if i conver to thumbnail i cannot use it in bigger size again...This loading can be one time...or many time....also images can be one or many and many....
so that's y im facing a problem when i load images in second time my first images are no longer display but i can c the images in imagelist....with empty previous imagelist.. so i gussed it could be, no display.May be bcz of i creat another image list again in second time
i just count the user selected image by using openDialogBox.FileNames.Length;
here is my coding...
private void import(object sender, EventArgs e)
{
if(listView1.Items.Count == 0)
{
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(100, 80);
imageList.ColorDepth = ColorDepth.Depth32Bit;
int i = 0;
string[] files = dlg.FileNames;
string[] pathes = new string[files.Length];
foreach (string file in files)
{
pathes[i] = file;
i++;
}
foreach (string path in pathes)
{
FileInfo fileInfo = new FileInfo(path);
String strDir = fileInfo.Name;
listView1.Items.Add(strDir);
imageList.Images.Add(Bitmap.FromFile(path));
}
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList;
}
}
A S E L A
|
|
|
|
|
I'm building some logic.
Inserting data from excel file of microsoft office.
So I made some logic like this
private DataSet ReadXLS(string FileName)
{
DataSet ds = new DataSet();
OleDbDataAdapter adapter;
string connectionString = @"provider=Microsoft.Jet.OLEDB.4.0;data source="
+ FileName + ";Extended Properties=\"Excel 8.0;Imex=1\"";
OleDbConnection conn = new OleDbConnection(connectionString);
try
{
adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", conn);
adapter.Fill(ds, strSheet);
}
catch
{
}
finally
{
if (conn.State == ConnectionState.Open) conn.Close(); }
return ds;
}
But this code has little problem.
The first line of excel sheet data is set to header column automatically.
In addition the header name automatically replaced to other characters
if it is number type.
I just want to get whole data from a excel sheet.
Help me.
|
|
|
|
|
I've been trying to find out how to find the preferred network connection (ex: WAN or LAN). There's a way to change the connection order in windows, but it doesn't seem like there are WMI classes that contain this connection order. Anyone know where to look/how to find the preferred connection?
|
|
|
|
|
Dns.GetHostAddresses("") appears to list the local IP addresses in the correct order with my current configuration, but its MSDN page[^] says nothing about the ordering, so it could be coincidence.
|
|
|
|
|
System.IO.IOException: Unable to read data from the transport connection: A system call that should never fail has failed. ---> System.Net.Sockets.SocketException: A system call that should never fail has failed
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
I'm not sure what to do with this. I saw this over 25 times in a log file today... I didn't see any hits for that string in Google either.
Hogan
|
|
|
|
|
I've seen it, but I just thought "what the heck? typically Microsoft". Unfortunately I don't know why it happens or what to do about it
|
|
|
|
|
snorkie wrote: I'm not sure what to do with this.
snorkie wrote: I didn't see any hits for that string in Google either.
Try this[^]
|
|
|
|
|
I'd have 9,000 posts on codeproject too if I spent all my time being a jackass. I even posted that I googled and didn't find anything. I should have posted that I didn't find anything helpful! I know what the exception is. My code caught and logged it... What I'm not sure about is what to do with it. The error code from the message, "A system call that should never fail has failed." is not exactly normal.
Hogan
|
|
|
|