|
Hi,
I actually facing problem in coding delimiter algorithm especially when user key in their entries in a rich textbox, the space that the user key in will be treated as delimiter ";".In other words, the space that user key-in after entering a word will be converted(interpreted) to ";" as delimiter symbol before user key in next word in the same line of text box as the second item.
Please give me some guidance or any available reference/samples available algorithm on this in C# code.I need to clarify my doubts on this as soon as possible.
Thanks..
|
|
|
|
|
Maybe you mean something like this:
string delimiter = ";";
textBox1.Text = textBox1.Text.Replace(" ", delimiter);
~Alexander Kent
|
|
|
|
|
Hi,
I actually facing problem in coding delimiter algorithm especially when user key in their entries in a rich textbox, the space that the user key in will be treated as delimiter (;).In other words, the space that user key-in after entering a word will be converted(interpreted) to ";" as delimiter symbol before user key in next word in the same line of text box as the second item.
Please give me some guidance or any available reference/samples available algorithm on this in C# code.I need to clarify my doubts on this as soon as possible.
Thanks..
|
|
|
|
|
Maybe you mean something like this:
string delimiter = ";";
textBox1.Text = textBox1.Text.Replace(" ", delimiter);
~Alexander Kent
|
|
|
|
|
The above line provided does make sense..but how am i going to check if user key in space (" ") in the particular text box, the ";" will be replace onto it and the pointer for next word is after the symbol ";"?
Thanks in advance,
Lee
|
|
|
|
|
You can try and use the TextBox SelectionStart property – something like:
In the KeyDown event
if (e.KeyCode == Keys.Space)
{
// Cancel the event
e.Handled = true;
// Use your delimiter
textBox1.Text += ";";
// Put the cursor after the newly appended text.
textBox1.SelectionStart = textBox1.Text.Length;
}
~Alexander Kent
|
|
|
|
|
Yea..I have tried and it only works in C# form but what I face the problem of delimiter lies in Web Application Form in C# Project Folder..(fyi, I am trying to put my C# application into Web Based)
I have tried to code the particular text box for the delimiter but it doesnt have SelectionStart function in Web Application.Thus, I used the previous code as below:-
private void TextBox3_TextChanged(object sender, System.EventArgs e){
string delimiter =";";
if (TextBox3.Text.EndsWith(" "))
{
TextBox3.Text += ";";
TextBox3.Text=TextBox3.Text.Repla ce(" ", delimiter);
}
}
With this code, I face another problem which is when i enter the input then";" doesnt come up automatically..it only comes up occasionally especially after I let the Validation Error appear in other textbox.
Please help me to clarify this doubt..I am stuck nowhere.
Thanks,
Lee
|
|
|
|
|
I'm confused.
If something is popped form the stack and stored in the 'local variable', where is it?
It's not on the stack?
What's distinguishing between the following?
1. The registers :
2. The Heap.
3. The 'stored local variable'.
4.As for the three above, how do I know 'what is where'??
See code below as an example...
//allocating and deallocating multiple variables on the stack
.ldstr "Hello World" //push this string on stack
ldstr "Goodbye World" //push second string on stack
stloc.0 //pop first string from the stack and store it in the local variable 0. // Huh? Where is it now?
|
|
|
|
|
SkunkedWorks wrote:
.ldstr "Hello World" //push this string on stack
ldstr "Goodbye World" //push second string on stack
stloc.0 //pop first string from the stack and store it in the local variable 0. // Huh? Where is it now?
it pops the top entry, iow the second string. if you dont understand this, go do some reading on stack behaviour. that value will be stored in the 1st local variable then, and only the 1st string will be left on the stack.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
leppie,
Thanks for your help.
1. WHERE IS the 1st local variable?
2.Where does one read about stack behavior?
|
|
|
|
|
Stack is the memory location where local variables are stored and other things that dont consume a lot of memory. This is done because there are not enough CPU registered to store everything.
You can read about CPU's, stacks, heaps, whatnot in a various assembly references. First thing that comes to mind is Art of Assembly, but I'm not sure if its a free resource anymore. Search in google and you should find a lot of stuff
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Alex Korchemniy wrote:
Stack is the memory location where local variables are stored
That's not exactly true. What stored on the execution stack are pointers to the variables, whether they be parameters, local variables or fields.
So, to answer the original question the local variable is at a certain address apart from the execution stack. When you use stloc.* it pops the variable referenced on the stack and assigns that reference to the applicable local variable.
The best way to learn about this stuff is to learn about computer architecture - specifically about memory addressing.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
> That's not exactly true.
Well its a simplistic answer.
|
|
|
|
|
I'll take a shot at this. To the best of my knowledge,
registers: small area of memory, located directly on the cpu, faster than conventional memory, used by the CPU for temporary storage, often used in calculations.
heap: the big pile of memory used (in .NET) for storing reference types. Everything on the heap, pinned references aside, is managed by the .NET garbage collector.
public class MyClass()
{
}
MyClass class = new MyClass();
The 'stored local variable': if it's stored locally in your function, it's on the stack until you pop it off the stack, in which case it'll be stored as a register variable. In your example, the 3rd line of IL will store the value on the top of the stack into a register variable I believe.
*waits for some expert to correct him*
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
I'm sure this is easy but I can't seem to find the answer. I want to close a form and open another without using Form1.Hide() and Form2.Show(). I want the first form to totaly close and the next form to be opened not as a child. Thanks
|
|
|
|
|
You can't close the form that your app starts on. If you do, you're entire app will quit. What you do in your Form1 Load event is create a Form2, like a splash screen, show it, complete all your initialization, and at the end of the Form1 Load event, destroy Form2.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yea, I ended up making them both separate threads and that worked
|
|
|
|
|
I am learning C# web development with Visual studio .NET and I cannot get past this error. Whilst working from a book i got the following error.
"A namespace does not directly contain members such as fields or methods."
I have included the code belowwhich was typed out of the book. It throws the error to line 75(near bottom). I have highlighted it. It is not happy with override protected void OnInit(EventArgs e. Namely override has red line in the API. I did not even type this part of the code in as it was webgenerated code. If anyone could point me in the direction I would be so Grateful as ths is for my Final year project at university.
Many thanks
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
//I removed using System.Drawing from here
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace FriendsReunion
{
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder phNav;
protected FriendsReunion.SubHeader ccSubHeader;
private void Page_Load(object sender, System.EventArgs e)
{
Table tb = new Table();
TableRow row;
TableCell cell;
Image img;
Hyperlink lnk;
if (Context.User.Identity.IsAuthenticated)
{
//Create a new blank table row
row = new TableRow();
//Set up the News image
img = new Image();
img.ImageUrl = "Images/globe.gif";
img.ImageAlign = ImageAlign.Middle;
img.Width = new Unit(24, UnitType.Pixel);
img.Height = new Unit(24,UnitType.Pixel);
//Create a cell and add the image
cell = new TableCell();
cell.Controls.Add(img);
//Add the new cell to the row
row.Cells.Add(cell);
//Set up the News link
lnk = new HyperLink();
lnk.Text = "News";
lnk.NavigateUrl = "News.aspx";
//Create the cell and the add link
cell = new TableCell();
cell.Controls.Add(lnk);
//Add the new cell to the row
row.Cells.Add(cell);
//Add the row to the table
tb.Rows.Add(row);
}
else
{
//code for authenticated users here...
}
//Finally, add the table to the placeholder
phNav.Controls.Add(tb);
}
}
}
#region Web Form Designer generated code
LINE 75 >>> override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
|
|
|
|
|
copy everything between
#region Web Form Designer generated code
and
#endregion
and move it inside the } brace just above where #region currently is.
|
|
|
|
|
cmitty wrote:
#region Web Form Designer generated code
LINE 75 >>> override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
This code block should be inside the class declaration. Move it a few lines up ( just before the last '}') and it'll work.
Yes, even I am blogging now!
|
|
|
|
|
Hi,
thank you for you quick response. I do not fully understand what you mean. I have tried moving it afew lines up but no joy. ths code is automaticlly generated. I have included all my code below. You may be able to see where I am going wrong. its bugging me now huh. Thanks for your help.
Chris
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
//I removed using System.Drawing from here
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace FriendsReunion
{
public class _Default : System.Web.UI.Page
{
protected FriendsReunion.SubHeader ccSubHeader;
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
Table tb = new Table();
TableRow row;
TableCell cell;
Image img;
Hyperlink lnk;
if (Context.User.Identity.IsAuthenticated)
{
//Create a new blank table row
row = new TableRow();
//Set up the News image
img = new Image();
img.ImageUrl = "Images/globe.gif";
img.ImageAlign = ImageAlign.Middle;
img.Width = new Unit(24, UnitType.Pixel);
img.Height = new Unit(24,UnitType.Pixel);
//Create a cell and add the image
cell = new TableCell();
cell.Controls.Add(img);
//Add the new cell to the row
row.Cells.Add(cell);
//Set up the News link
lnk = new HyperLink();
lnk.Text = "News";
lnk.NavigateUrl = "News.aspx";
//Create the cell and the add link
cell = new TableCell();
cell.Controls.Add(lnk);
//Add the new cell to the row
row.Cells.Add(cell);
//Add the row to the table
tb.Rows.Add(row);
}
else
{
//code for authenticated users here...
}
//Finally, add the table to the placeholder
phNav.Controls.Add(tb);
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent1();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent1()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
|
|
|
|
|
I have just made a control that is resizable. The resizing is performed with the mouse, in the normal windows way. You put the mouse on the resizer box and drag it to desired shape.
I have currently made this work for bottom and the right side of the control. When I resize using those resizers everything works fine. When I drag them with the mouse the control is smoothly updated. Here I update the controls width and height properties.
But when I try to do the same thing with the top and left side of the control, things dont work as with the bottom and right side. The control gets strange shapes until I release the mouse button and still it doesnt get the correct shape as I would expect. It kind of works, it resizes in the right directions atleast, but not always in the correct distances, and the resize is definately not smooth, it looks completely screwed up during the resize and flickers and everything. The only difference I can see between these edges of the control and the bottom and right is that the top and left sides need to change the controls Top and Left properties and not just its Width and Height. The code is basically exactly the same for all resizes so it seems really strange to me.
|
|
|
|
|
Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ?
~Alexander Kent
|
|
|
|
|
Yes I have overridden the OnPaint event, and I really dont know whether the use of invalidate is excessive or not, but it works for the bottom and right sides of the control, and I invalidate them just as much as I invalidate the top and left sides.
The source code is maybe a little too long to show here but if anyone wants to see it I'll be glad to send it to you.
|
|
|
|
|
Keen to take a look at your code
~Alexander Kent
|
|
|
|