|
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 )
|
|
|
|
|
Thanks Christian!
I understand your points. My point is just to "learn more". Do you have any reference documents or tutorials about the topic of access modifier of class level? I think I missed this part of knowledge.
regards,
George
|
|
|
|
|
As is often the case, I have no idea what you're asking, but I think you're over complicating things. The access modifier is private, protected or public. I can't imagine too much has been written beyond explaining the difference between the three.
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 )
|
|
|
|
|
Sorry, Christian!
My English is not good. I mean what are the restrictions of public/protected/private classes? Are there any documents for them?
regards,
George
|
|
|
|
|
OK - got it. The only restriction is, who can create them. The use of a private class is to define a class within another, that cannot be created outside that class. For example, I may use a class to define a group of values within the class, but not want a user to ever create an instance of 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 )
|
|
|
|
|
Thanks Christian,
I almost get your ideas. Are there any MSDN or other documents? It is strange I can not find any related documents about public/protected/private classes.
regards,
George
|
|
|
|
|
The concept is so simple that it doesn't warrant a lot of documentation. There's really not much more to say. Your best bet is to google the error message in quotes, to get the MSDN explanation
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,
Can I understand the root cause of my original issue in this way? The class is not public (default private?) and the type inside the class is public -- more visibility then outer type?
regards,
George
|
|
|
|
|
Correct
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 think for Enum, it is treated as a type, so a non-public class can not have a public nested Enum type.
And for methods, it is not under this rule, e.g. a non-public class could have a public method. Correct?
regards,
George
|
|
|
|
|
As Christian said, you are really complicating things. It's okay to learn and ask questions about specific problems. But for some little things like this there's no need to buy a book or read dozens of pages. The compiler warns you about a very common problem which you could have solved by adjusting the access modifiers to suit your needs.
modified 12-Sep-18 21:01pm.
|
|
|
|
|