|
Hi,
When you create a Form with the Designer, VS2005 (maybe earlier?) adds code to override the Dipose(bool) method as follows:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Every time I step through this function in the debugger, components always == null. Am I supposed to be allocating components and adding items to it manually, so that they will be disposed?
|
|
|
|
|
I'm moving from VB to c#, I'm getting there, but one thing has be baffled.
How do i define the length of a string?
for example, if i wanted a string exactly 20 bytes long?
Thanks
|
|
|
|
|
You don't define the length of the string. You just set the string to what you want it to be, e.g.
string myString = "hello world!";
If you need to have a string of a certain length, use a char[] instead, e.g.
char[] theCharacters = { 'h', 'e', 'l', 'l', 'o' };
or alternately
char[] theCharacters = new char[20];
|
|
|
|
|
Thanks for the speedy reply, it was helpful
Looks like my program needs a rewrite ^^
|
|
|
|
|
Although characters aren't necessarily bytes anyway.
|
|
|
|
|
hi all,
i deeply hope that you guys have an answer to my question which is the following:
i've got a menu which controls a couple of user controls representing the pages of my app. only the currently selected page is visible. my problem is that when I resize my app and then switch to another (formerly hidden) page and change its visibility to visible it first paints int its old size and afterwards resizes itself to match the new parent proportions. So basically it is painting twice which is pretty ugly.
Does anyone know how to handle this problem? I'm pretty much stuck
I'd appreciate any help,
thx, Bjoern
|
|
|
|
|
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
|
|
|
|
|
Many different ways you can go abouts doing this. SQL Substring Function[^] may help guide your way
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i think you're looking to use the "LIKE" clause of SQL.
In your SQL statement you'll be doing something like this:
<br />
string myStr = "world";<br />
<br />
string sSQL = "SELECT field from table where field LIKE @mystr;";<br />
<br />
dbcommand.parameters.addwithvalue("@mystr",myStr);<br />
<br />
string mydbvalue = dbcommand.executescalar();<br />
|
|
|
|
|
What would "LIKE" return in this condition:
String to be found:"????2805"
and string that is checked is "2805-2705"
it will still find the sub-string but this is not what we were looking for.... wont it...
|
|
|
|
|
Hello,
I have a DataGrid (not DataGridView) control .NET 2.0 bound to a given DataTable. One of the columns contains alphanumeric values which do not get sorted well: e.g. take the IDs A-12, A-103, B-3, ... Z-0. The default sorter of the DataGrid sorts the first two items incorrectly (A-103, A-12).
If I used a custom IComparer implementation I would call string.CompareOrdinal in order to obtain the actual compare result but apparently data-bound grids cannot be sorted that way.
I would definitely appreciate any suggestions to resolve this issue. I think this can be achived by creating a derived Control or by handling the SortCompare event of the DataGridView control.
Thanks,
Stanimir
|
|
|
|
|
Hi,
when I try to evaluate a member in debug mode by pointing on a variable to see its content, the data that is displayed is i hexadecimal. For example, I do the following instruction:
int t=-1;
After passing the instruction, I try to see the content of the variable 't' and what I see is '0xffffffff '.
All the data I try to evaluate appear using the same notation.
Do you know how I can change that to see them in decimal ?
Thanks a lot for attention.
Patrick.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Right click on the variable display and the popup menu has an option for hexadecimal. Just uncheck it.
|
|
|
|
|
Thanks for answering. But, there is no option for hexadecimal, so I can't uncheck it.
I'm working with Visual Studio 2005.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
It's there. It's called Hexidecimal Display.
|
|
|
|
|
Ok, I found it. But it's not directly available in the popmenu displayed after pointing a variable. I did it from the 'Watch' window.
Thanks !
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Try this:
As you're debugging, go to the locals (or watch) panel. Select a variable (name, value, type) and right click. It lets you toggle the hex display.
|
|
|
|
|
It works this way. Thanks for replying !
Pat.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
I am in the process of creating a program that needs to extract the below data from an ASP then populate a dataGridView. I only need to extract certain information but not all information. AS an example I need to look for "TCatalog:" and then the text after wich could be "OK" or Off-Line". What I don't need is the Overhead or the Heap Error Code.
TCatalog: OK<BR>DATSVR: OK<BR>Server IP: xxx.xxx.xxx.xxx<BR>Server Port: xxxx<BR>Socket Count: 1<BR>CC/ProgID: XX/XXXX<BR>Site Style: STD<BR>Program Name: Program Name<BR>Client Name: comapny Name<BR>Catalog Started at: 7/30/2007 10:33:42 AM<BR>Total Sessions: 8<BR>Current Sessions: 19<BR># Orders Received: 0<BR>Total Amount of Orders: 0.00<BR>Last Logged Request: 7/30/2007 10:33:42 AM<BR># Errors Logged: 17<BR># DB Errors Logged: 0<BR>Customized Pages: CartCheckOut.Asp,Main.Asp
<BR>Last Published: 07/13/07 10:00 by XXX<BR>Data Updated: 07/13/07 10:00 by CMG<BR>Memory Status (Heap): <br> Total Address Space: 12648448<br> Total Uncommitted: 1802240<br> Total Committed: 10846208<br> Total Allocated: 9250932<br> Total Free: 779084<br> Free Small: 487808<br> Free Big: 291276<br> Unused: 0<br> Overhead: 816192<br> Heap Error Code: 0<br>End of SiteCheck<BR>
|
|
|
|
|
Ummm did you have like a question or something? wait.... never mind
|
|
|
|
|
For that task, the string methods are also good enough!
string AllText="TCatalog: OK<BR>DATSVR: OK<BR>";
string searchstring ="TCatalog:";
string result="";
int startindex = AllText.IndexOf(searchstring);
if(startindex>=0)
{
int endindex = AllText.IndexOf("<", startindex);
if(endindex>=0)
{
result= AllText.Substring(startindex+ searchstring.Length, endindex- searchstring.Length).Trim();
}
}
All the best,
Martin
|
|
|
|
|
I am not sure I follow if the text that I am looking for after TCatalog and DATSVR could be either OK or Off-Line. I am going to pull data from about 40 different pages every 15 minutes or so to get new values. As you can see some of the feilds are dollar values so I will need to replace the old value in the dataGrid and also I will be adding a total value in a label.
Thanks the quick replies.
|
|
|
|
|
Use the Expresso tool found on this site to help with regular expressions
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi
I have an application which runs a login screen before the main program runs.
The login only succees when the user enters the right credentials.
The login screen is loaded to show as a dialog. When it closes the main class is run which is tha actual application. I need to access a property which I created in the Login screen's class, in the form_load event of the main class.
However I cannot access the variable which is declared in the Program.cs which is used to load the login screen. It keeps telling me : "The name 'frmTheLogin' does not exist in the current context"
Here the Program.cs code :
namespace ChequeApp
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
frmLogin frmTheLogin;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmTheLogin = new frmLogin();
if (frmTheLogin.ShowDialog() == DialogResult.OK)
{
Application.Run(new frmChequeApp());
}
}
}
}
Here the Login class code :
namespace ChequeApp
{
public partial class frmLogin : Form
{
private string strUsername; //private variable for username.
IntPtr iptrTheToken;
private Int32 intAccessRight;
//Read-only property for username.
public string Username
{
get
{
return strUsername;
}
}
//Read-only property for the access rights.
public Int32 AccessRight
{
get
{
return intAccessRight;
}
}
...
}
Here the main class code :
namespace ChequeApp
{
public partial class frmChequeApp : Form
{
private string strUsername;
private Int32 intAccessRight;
private System.Windows.Forms.UserControl ctrlChequeApp;
public frmChequeApp()
{
InitializeComponent();
}
private void DisposeControl()
{
if (ctrlChequeApp != null)
{
this.Controls.Remove(ctrlChequeApp);
ctrlChequeApp.Dispose();
ctrlChequeApp = null;
}
}
private void ShowControl()
{
ctrlChequeApp.Location = new Point(1, 1);
this.Controls.Add(ctrlChequeApp);
ctrlChequeApp.BringToFront();
ctrlChequeApp.Dock = DockStyle.Fill;
}
private void frmChequeApp_Load(object sender, EventArgs e)
{
strUsername = frmTheLogin.Username; //IT ERRORS HERE
intAccessRight = frmTheLogin.AccessRight; //IT ERRORS HERE
}
...
}
|
|
|
|
|
Oederu wrote: It keeps telling me : "The name 'frmTheLogin' does not exist in the current context"
You don't understand "scope" and yet your are writing an application which requires logging in.
|
|
|
|