|
i didnt see leppies post bofore i posted mine, use the textBox.Lines(as leppie said) property like this
string[] myArray = textBox1.Lines;
foreach (string myString in myArray)
{
if (myString.StartsWith(@"$GSV"))
{
MessageBox.Show("Found One");
}
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi, HarveySaayman, I found this code is very useful and I can get what I want with this code. Thank you very much.
Have a nice day~!
|
|
|
|
|
Hi, HatveySaayman, can you tell me why the code you put in the bracket is @"$GSV" but not "$GSV"? Is it because the string is begin with a '$'? Sorry to ask a question like this, I am a newbie in C#. Thank you for your kind helping.
|
|
|
|
|
hey
the @ infront means that the string in between the "'s are literals, if you dont have the @ infront and the user has for example a \r(return escape character)someware in the textbox this will be seen as a return character. where if the @ is infront it will be seen as "\r".
the @ basically ignores escape characters like \r or \n ect...
hope that makes sense
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: hope that makes sense
Not really, it's \ not / !
|
|
|
|
|
oops! my bad i fixed it
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
I would like to have a header/title on top of property Grid like a frame.
But I found only toolbarvisble option is available.
How to have a header on a property Grid ?
Thanks,
Rajan
|
|
|
|
|
Just wrap the grid and a label in a panel.
|
|
|
|
|
Hi all,
I am planing to have 2 panel, p1 and p2. Is possible the p1 content can scroll by p2's scrollbar(vertical or horizontal)?if yes,how can i make it?
any information or articles are welcome.Thanks
regards
cocoonwls
|
|
|
|
|
hey,
im not sure if this is directly posible, BUT you could use events to attempt it...
if there is an event like scrollBarMoved on p2 you could try to override it and send the args to p1 and then move its contents around as you wish.
these are simply ideas ment to get you thinking, i have no idea if this will work
good luck
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi,
thanks for your reply.I think i am miss up 1 question here.I am already add the Vscrollbar in my panel and set the max,min and smallvalue in the Vscrollbar.It display in my form but i can't scroll the content in the panel.Can you please give me a direction to make it?
thanks in advance
cocoonwls
|
|
|
|
|
heres what you need to do...
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
int difference = e.NewValue - e.OldValue;
foreach (Control ctrl in myPanel.Controls)
{
if (ctrl.GetType() != typeof(VScrollBar))
{
ctrl.Location = new Point(ctrl.Location.X, (ctrl.Location.Y + difference));
}
}
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi,
Thank you very much, your first suggestion and the second suggestion work great for me
regards
cocoonwls
|
|
|
|
|
glad to help cocoonwls
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi,
BTW,how can i calculate the smallchange and largechange value?any related information are welcome..
thanks in advance
cocoonwls
|
|
|
|
|
Hi all,
I would like to know, how can I set the format of the date and time (regional settings) on a computer.
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
If someone wants to know the following[^] will help ...
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi Im a newbie to c#
I want to connect to access 2007 db which has usernames and passwords stored in a table called USERS
If there is a username and password in the db that matches what the user has entered into the textboxes in the form then the form1 can be displayed otherwise an error message is displayed.
Heres my code so far
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Xml.Serialization ;
using ADODB;
public partial class login : Form
{
private ADODB.Connection cn = new ADODB.Connection();
private ADODB.Recordset rs = new ADODB.Recordset();
private string cnStr;
private string query;
public login()
{
InitializeComponent();
}
private void login_Load(object sender, EventArgs e)
{
//Connection string.
cnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\resources\pw.accdb;Persist Security Info=False;";
//query
query = "Select * From USERS";
//Connection via Connection open Property.
cn.Open(cnStr, null, null, 0);
cn.Close();
//Connection via ConnectionString Property.
cn.ConnectionString = cnStr;
cn.Open(null, null, null, 0);
cn.Close();
}
private void btnLOGIN_Click(object sender, EventArgs e)
{
//Open Recordset via Connection object. retrieves the recordset from the db
cn.Open(cnStr, null, null, 0);
rs.Open(query, cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
rs.Close();
cn.Close();
string command = "SELECT UN, PW FROM USERS";
//NOW CONFUSED HERE - DONT KNOW WHAT TO DO NEXT
}
}
Basically all I need in c# code is the following pseudo code;
Button submit_Click()
select un, password from users
if txtun.text = UN and txtpw.text = PW
me.hide
form1.show
else
msg(Error - Your input details are incorrect);
end if
Please help as I've been over it several times.
Thanks
JB
|
|
|
|
|
hey jb,
first of all please use pre tags when you posting so much code, no on wants to read non-indented code...
try using this query
SELECT COUNT(userID)
WHERE userName = 'yourUserNameTextBoxText' AND password = 'yourPasswordTextBoxText'
then in the program just check that the return value of that query == 1; if not there was no match therefore either the username or password was incorrect
good luck
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
In a Page (there is no async=true tag); i call a procedure asynchrously. Sometimes it calls the callback; sometimes not. Why do i face this reason?
private void AsynchronProcedure()
....
try
{
dbSqlConnection.Open();
IAsyncResult asyncResult = dbSqlCommand.BeginExecuteNonQuery(MyCallBack, dbSqlCommand);
}
catch (Exception ex)
{
}
finally
{
dbSqlConnection.Close();
}
}
private void MyCallBack(IAsyncResult asyncResult)
{
SqlCommand dbSqlcommand = (SqlCommand)asyncResult.AsyncState;
try
{
if (asyncResult.IsCompleted)
{
dbSqlcommand.EndExecuteNonQuery(asyncResult);
}
}
catch (Exception ex)
{
}
}
|
|
|
|
|
greekius wrote: In a Page (there is no async=true tag); i call a procedure asynchrously.
Two different things. The former for for page handling. The latter is you. Neither has an effect on each other.
greekius wrote: Sometimes it calls the callback; sometimes not. Why do i face this reason?
Your code is wrong. You should close the connection after the callback returns, not before it (as you are doing now, not really, it depends, but the fact is the connection can and likely will be closed before the async call can complete).
|
|
|
|
|
Hello everyone,
For the following code, the compile error is,
error CS0051: Inconsistent accessibility: parameter type 'TestEnum1.Goo.Level' is less accessible than method 'TestEnum1.Foo.Test(TestEnum1.Goo.Level)'
My fix is to make class Goo public, is it correct fix? Why there is such compile error?
class Goo
{
public enum Level
{
Error = 0,
Warning = 1
}
}
public class Foo
{
static public void Test(TestEnum1.Goo.Level l)
{
return;
}
}
thanks in advance,
George
|
|
|
|
|
Gosh George, you post here so much, and you can't understand this error message ? The class is public, the method is public, but Goo is not public. How can someone call Foo.Test, if they have access to this method, but not access to the type of class they need to pass in ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
I have did some search in MSDN, about access modifier for class level, other than for method level. But I can not find any information. Any recommended links? I feel as you said, the root cause is my knowledge about access modifier for class level.
regards,
George
|
|
|
|
|
Well, isn't it clear ? You are exposing a method which takes an object. It's possible for someone to have access to the method, but not to the object that needs to be created. Therefore, your intention appears to be to expose a method, but unless you make that other class public, your user won't be able to call it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|