|
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.
|
|
|
|
|
frmChecqueApp has no knowledge of frmTheLogin since they are in separate scopes.
You need to make frmChecqueApp aware of the form (and preferably only the data from the form that you want access to).
My suggestion would be to pass in the username and accessright into frmChecqueApp's constructor as follows:
public frmChequeApp(string userName, Int32 accessRight)
{
InitializeComponent();
strUsername = userName;
intAccessRight = accessRight;
}
and then in your Program.cs you would change it to:
namespace ChequeApp
{
static class Program
{
[STAThread]
static void Main()
{
frmLogin frmTheLogin;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmTheLogin = new frmLogin();
if (frmTheLogin.ShowDialog() == DialogResult.OK)
{
Application.Run(new frmChequeApp(frmTheLogin.UserName, frmTheLogin.AccessRight));
}
}
}
|
|
|
|
|
Thank You that helped a lot. I thought that all components/variables in the
base class could see each other but that is not so. Now I know. Thanks again.
|
|
|
|
|
Hello,
I am trying to fill a datagridview with a very large file (about 600 000 rows), i keep getting a ("Exception of type 'System.OutOfMemoryException' was thrown.")Error, but I do not see how I could be out of memory. Is there a max amount of rows that a data grid view can hold?
Hope some one can help
J
|
|
|
|
|
jasper018 wrote: but I do not see how I could be out of memory
Just a wild guess but maybe memory is not an infinite resource
Use "virtual mode" see the documentation for details
|
|
|
|
|
Hi,
I am facing a problem while using pepared statement for inserting data in MS-Access db.
<code>private const String CONN_STR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Temp\\TestDb.mdb";
conDatabase.Open(CONN_STR, "", "", -1);
String sQuery = "INSERT INTO " + sTableName +
" ([FileName],[IsCopied],[Size]) VALUES (@FileName,@IsCopied,@Size)";
cmdPrepStmnt.ActiveConnection = conDatabase;
cmdPrepStmnt.CommandText = sQuery;
cmdPrepStmnt.CommandType = CommandTypeEnum.adCmdText;
cmdPrepStmnt.Prepared = true;
int iCount = 0;
foreach (FileInfo f in fInfo)
{
Console.WriteLine("Adding File " + ++iCount + " of " + fInfo.Length + "; " + f.Name);
Parameter p1 = cmdPrepStmnt.CreateParameter("@FileName", ADODB.DataTypeEnum.adVarWChar, ParameterDirectionEnum.adParamInput, 255, f.FullName);
Parameter p3 = cmdPrepStmnt.CreateParameter("@IsCopied", ADODB.DataTypeEnum.adBoolean, ParameterDirectionEnum.adParamInput, 10, false);
Parameter p5 = cmdPrepStmnt.CreateParameter("@Size", ADODB.DataTypeEnum.adInteger, ParameterDirectionEnum.adParamInput, 10, f.Length);
cmdPrepStmnt.Parameters.Append(p1);
cmdPrepStmnt.Parameters.Append(p3);
cmdPrepStmnt.Parameters.Append(p5);
cmdPrepStmnt.Execute(out objAffected, ref obj, 0);
}
</code>
FileName is coming as blank in db, while in debug mode i can see that it is being set with a proper filename. The other 2 params are inserting fine.
The FileName field is set as Text field with width length 255, and the incoming data is always shorter than 255 chars. The insertion happens without any errors/exceptions. I have also tried replacing the data for filename with a string like "Test", still it is inserting blank string.
Please help.<code></code>
|
|
|
|