|
What actually do u want to do?
And comments about wht?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Comments:
shyamy wrote: int Count=txtEnter.Text.Length,i=0;
Local variables are generally named with the first character in lower case, e.g. count instead of Count .
There is no reason to initalise the variable i , as you are not using it before you initialise it again in the loop.
for(i=Count;i>0;i--)
Why are you looping from Count to 1 instead of from Count-1 to 0?
txtChange.Text+=myString.Substring(i-1,1);
Use a StringBuilder to build the string. That way you don't create so many string objects. Using the += operator to concatenate strings scales very badly; the execution time increases exponetially for each character you add.
Instead of using SubString , use the indexer to get the character: myString[i-1] , that way you use a char value to handle the character instead of creating another string object.
---
b { font-weight: normal; }
|
|
|
|
|
private void btnChange_Click(object sender, System.EventArgs e)<br />
{<br />
int Count=txtEnter.Text.Length;<br />
<br />
int i=0;<br />
<br />
string myString=txtEnter.Text;<br />
<br />
for(i=Count;i>0;i--)<br />
{<br />
txtChange.Text+=myString.Substring(i-1,1);<br />
}<br />
}<br />
<br />
<br />
private void btnExit_Click(object sender, System.EventArgs e)<br />
{<br />
this.Close();<br />
}
Hope this helps
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates
|
|
|
|
|
Hi,
I am trying to print multiple labels using response.binarywrite() and i am getting only 1 image.I am attaching the code with this please help me out.
protected void Page_Load(object sender, EventArgs e)
{
int count = Convert.ToInt32(Session["PkgCount"]);
for (int i = 0; i
|
|
|
|
|
Are you trying to send multiple images in the same response? That is not possible. If you want them in the same response, you have to create a larger image and draw the images onto it, so that you can send it as a single image.
---
b { font-weight: normal; }
|
|
|
|
|
Hi guffa,
I dont want to dispaly it as a single response. It is a response from UPS server and i am trying to write it in to a browser. Please look in to the code and suggest me a good solution.
|
|
|
|
|
I can't suggest any solution, as I don't know what it is that you are trying to do.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
I am trying to print multiple label images in case of ups multi label implementaion. The response i get in XML schema and from that i parsedout the label images and stored in an array and from that array i am trying to print the labels in to Response. So many images are there and i am getting only one image the rest are getting overwritten. Because of this i am not able to release the product. i searched a lot in the net but i havn't got a good result from there. Please help me out with this problem
|
|
|
|
|
Ok, so then you are trying to show them in a single response, although you said that you didn't.
A response can only consist of one item. One html document, one image or one file. What you have managed to create is a response that contains one image with a lot of garbage data appended to it. The garbage data is of course the other images that you tried to put in the same request as the first image. The other images are not being overwritten, as you thought, only ignored.
As I explained before, you can't send multiple images in one response. If you have multiple images and want to send them in the same response, you have to put them together into a single image.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
Could you please tell me how to put the multiple images together. I tried out with an arraylist but that was a failure. Please advice me on this
|
|
|
|
|
Create a Bitmap large enough to contain the separate images, get a graphics object for the Bitmap by using the FromImage method of the Graphics class, and use that to draw the separate images onto the Bitmap. Save the Bitmap to the response stream.
---
b { font-weight: normal; }
|
|
|
|
|
we have already converted it to .bmp format in the prevous page. I am reallu stuck up with this problem.
Bitmap bmp = new Bitmap((Bitmap)System.Drawing.Image.FromStream(mem));
MemoryStream label = new MemoryStream();
bmp.Save(label, format);
please tell me a possible solution.
|
|
|
|
|
A Bitmap object is not the same as a .bmp file.
Read my previous post for the solution.
---
b { font-weight: normal; }
|
|
|
|
|
Hi im writing a classes for a TcpConnection that works with the Socket-Mehtods.
In my class i wanna fire an event when i got Bytes and i do that with the BeginReceive- and EndReceive-Methods.
But when i fire an event from the AsyncCallBack-Methode that i have to set with the Socket.BeginReceive-Methode, then i got and InvalidOperationException when i handle
the event in an Form
Here the class example
<code>
public class TcpConnection {
public delegate void ReceiveDataEventHandler( byte[] e );
public event ReceiveDataEventHandler ReceiveData;
public Socket m_connectionSocket;
public byte[] m_receiveBuffer;
public TcpConnection() {
m_connectionSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
}
public void startReceiving() {
m_receiveBuffer = new byte[ m_connectionSocket.ReceiveBufferSize ];
m_connectionSocket.BeginReceive( m_receiveBuffer, 0, m_receiveBuffer.Length,
SocketFlags.None, new AsyncCallback( receiveDataBytes ), m_connectionSocket );
}
private void receiveDataBytes( IAsyncResult asyncResult ) {
Socket thisSocket = ( Socket ) asyncResult.AsyncState;
int dataBufferLength = thisSocket.EndReceive( asyncResult );
byte[] dataBuffer = new byte[ dataBufferLength ];
Array.Copy( m_receiveBuffer, dataBuffer, dataBufferLength );
if( ReceiveData != null ) {
ReceiveData( dataBuffer );
}
thisSocket.BeginReceive( m_receiveBuffer, 0, m_receiveBuffer.Length, SocketFlags.None,
new AsyncCallback( receiveDataBytes ), thisSocket );
}
}
</code>
and here the handling of the event in a form
<code>
public partial class Form1 : Form {
private Socket localSocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
public Form1() {
InitializeComponent();
Socket newConnection = localSocket.Accept();
TcpConnection myConnection = new TcpConnection( newConnection );
myConnection.ReceiveData += new TcpConnection.ReceiveDataEventHandler( receiveDataEvent );
myConnection.startReceiving();
}
private void receiveDataEvent( byte[] data ) {
this.Text = System.Text.Encoding.ASCII.GetString( data );
}
}
</code>
My question is now.....how do i fire the event right, so that i can access the form-elements normaly like in the other eventhandler-methods
-- modified at 11:01 Monday 27th November, 2006
|
|
|
|
|
The problem is that you fire the event on a thread other than the main UI thread and it's not allowed to access UI controls from threads other the one they were created on as this can trigger unexpected behaviour e.g. freezing your app. You have to handle this on your event handler in the following way:
private void receiveDataEvent(byte[] data)
{
if (this.InvokeRequired)
{
this.Invoke(new ReceiveDataEventHandler(this.receiveDataEvent), data);
}
else
{
}
}
For some more information on invoking take a look at the following article: What's up with BeginInvoke?[^]
Last but not least: Please always put pre tags around multiline code snippets as this preserves indentation and therefor makes the snippet much more readable.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hi Stefan, thx for the quick answer =)
OK, i see how that work with this.InvokeRequired...
...but can you tell me what i must do so that i can use my events like the other events fired from microsoft-Classes,
example -> System.IO.Ports.SerialPort.DataReceived-Event
they dont need to go over this.InvokeRequired =/
|
|
|
|
|
Quoting MSDN topic for SerialPort.DataReceived Event[^]:
The DataReceived event is raised on a secondary thread when data is received from the SerialPort object. Because this event is raised on a secondary thread, and not the main thread, attempting to modify some elements in the main thread, such as UI elements, could raise a threading exception. If it is necessary to modify elements in the main Form or Control, post change requests back using Invoke, which will do the work on the proper thread.
If you used the DataReceived event without trouble, you probably accessed no Ui controls or were lucky.
Ensuring that an event handler is executed on the right thread is no concern of the event with no difference between custom events and the ones provided by classes of the framework class library.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Just maybe i am a bit newbie in c#, but got such a problem...
private void Form1_Load(object sender, EventArgs e)
{
this.grupeTableAdapter.Fill(this.bangaDataSet.Grupe);
}
Cant to insert any new information to my db.
string one = textBox1.Text;
string two = textBox2.Text;
this.grupeTableAdapter.Insert (Convert.ToInt32(one), Convert.ToString(two));
this.grupeTableAdapter.Fill(this.bangaDataSet.Grupe);
bangaDataSet.AcceptChanges();
Assigned all this to button, but nothing happens. In db one column is numbers other just information... Maybe anyone know, how to update that information, what could be bad ? Or at all all this code is bad ?
Sorry for my bad english
|
|
|
|
|
hello every body,
I've a problem in CrystalReport 11.5 with VisualStudio.net 2005 C#.
i've installed the CrystalReport XI release2, service pack1 and hot fix, now i've been saw the CrystalReportViewer 11.5 in VisualStudio.net 2005 C# and i'm try to set the report source but there is an exception thrown to notify of ReportSource is write only!!
can any one have an idea reply please
Thanks
Bahaa
|
|
|
|
|
yes i've the same problem,
not ReportSource only, all properties are closed and u cannot change it in run time.
can any one help plz?
21mh
|
|
|
|
|
Hi all,
I want to send a html file to the printer...
So far i have the following...
<br />
string _filePath = "C:\\newFolder";<br />
Process myProcess = new Process();<br />
myProcess.StartInfo.FileName = _filePath + "\\test.HTML";<br />
myProcess.StartInfo.Verb = "Print";<br />
myProcess.StartInfo.CreateNoWindow = true;<br />
myProcess.Start();
I can get it to print BUT i don't want the user to select the printer because the user already selected the printer he wants to use and i saved this selection. How can i use the selected printer previously saved as the printer to use now when the file needs to be printed?
The segment above brings up a window where all the found printers are shown and when one is selected the printing of the html file begins.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Salaam (Peace upon all)...
I m Ahsan doing MCS..
I need to know that how can i show the Records from an Access Database Table on a Datagrid View in C# 2005.
will be very thankfull for ur concern..
Regards and Best of Luck for ur Future.
Ahsan Zohaib
|
|
|
|
|
|
Hi...
If i want my datagridview control to show one column as combobox & other two columans as textbox. I want first two columan as read only textboxes for user & 3rd column is used by user to select the values by a Dropdown combobox...
Is it possible to do this...How can i do this...? how can i add rows in DataGridView...? How i can add range of data in Combobox column...?Can anybody give me link for any good Documnet on DataGridView which explains this...?
Thanks,
Vinay
|
|
|
|
|
Since you're talking about a DataGridView (DGV) compared to a DataGrid(DG), I'll assume you're using VS2005.
Check out the CP article Here[^]:
I ended up buying the book and its a great reference for all your windows forms databinding/datamanagement needs.
|
|
|
|