|
Hello
Retrieving such information can not be done using C# usually. You'll have to either use interrupts - eg. INT21H- or access BIOS directly. Both of which requires good knowledge of assembly language, and a hardware background. Also if it's possible in one motherboard, it could be not in another, ie. it's a hardware specific procedure with quite some variations.
Regards
|
|
|
|
|
|
Hai Friends
Is there any sample/ Open source or Article that decribes how to code ISO 8583 Formatter in C#.
Please help me . its so urgent.
Thanks in advance
|
|
|
|
|
The above code (C#)works as fare as the MessageBox.Show("The name of the second column is " + colSecond.ColumnName); can answer the question so the connection to the database is okay .. But no data are shown in the datagrid..
Whats wrong.. guess its something to do with the databinding ??
MySqlConnection cnnVideos = new MySqlConnection("Database=tiebreak;Data Source=localhost;User Id=root;Password=test");
cnnVideos.Open();
string strVideos = "SELECT * from member;";
MySqlCommand cmdVideos = new MySqlCommand(strVideos, cnnVideos);
MySqlDataAdapter dadVideoCollection = new MySqlDataAdapter(cmdVideos);
DataSet setVideos = new DataSet("member");
dadVideoCollection.Fill(setVideos);
dataGrid1.DataSource = setVideos;
dataGrid1.DataMember = setVideos.Tables[0].TableName;
dataGrid1.SetDataBinding(setVideos, "member");
DataColumn colSecond = setVideos.Tables[0].Columns[2];
MessageBox.Show("The name of the second column is " + colSecond.ColumnName);
cnnVideos.Close();
-- modified at 20:26 Tuesday 8th August, 2006
|
|
|
|
|
dataGrid1.SetDataBinding(setVideos, "member");
see !you can chang the sequence like dataGrid1.SetDataBinding("member",setVideos);
|
|
|
|
|
Hmm excuse me, but I didn't understand your reply ..
First of all, I currently had it like dataGrid1.SetDataBinding(setVideos, "member"); .. And no I cant change the order, it will give compile errors.. ? what where the problems that you saw ?
|
|
|
|
|
Tried to add the following:
DataSet setVideos = new DataSet("setVideos");
setVideos.Tables.add(new DataTable("name"));
setVideos.Tables.add(new DataTable("adress"));
but it returns the following error:
System.Data.DataTableCollection' does not contain a definition for 'add'
|
|
|
|
|
Hi,
I just know this is a dumb simple question BUT I can't figure it out .
I'm trying to break my code into several codefiles to make it easier to follow. I thought all you had to do was use the same namespace declaration in each of them and then the code/methods in those *.cs files would be freely "interchangeable" and usable.
I've added codefiles using the add to project options in Solution Explorer, used the same namespace in the new codefile but I can't use a method in the main code file that is located in the other codefile.
When I reference the method I keep getting the error "The name 'getYMDHMS' does not exist in the current context".
Can someone be kind enough to put me out of my misery and tell me what I'm doing wrong .
Thanks,
Glen Harvy
|
|
|
|
|
Hmm, when you say you can't use a method in the main code file that is located in another codefile, do you mean that you can't use the class that contains the method in one file in another file?
Let's say you have a file in your project called Program.cs. I'm assuming that we're creating a console application program. Here is what the Program.cs file looks like:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
Now, let's add a second file, actually we'll be adding a second class that will be contained in a second file. We'll call it MyClass.
Go to Project->Add New Item
Choose Class, and type MyClass in the edit box. Then press the Add button.
Visual studio has created a second file for use called MyClass.cs. It looks like this:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class MyClass
{
}
}
Let's add a static method to MyClass that we can call from the Main method in the Program class:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class MyClass
{
public static void PrintHello()
{
Console.WriteLine("Hello!");
}
}
}
Change the Main method in the Program class located in the Program.cs file to look like this:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyClass.PrintHello();
Console.Read();
}
}
}
Run the program.
To review: We've created a console application and added a second class called MyClass contained in a second file called MyClass.cs. We called a static method in MyClass from the Main method in the Program class.
Does this example help?
If you need more information, let me know.
|
|
|
|
|
Leslie Sanford wrote: Does this example help?
Are you kidding - without your help I would still be lost .
Leslie Sanford wrote: do you mean that you can't use the class that contains the method in one file in another file?
Yes - that's exactly what I mean BUT I can only say that AFTER I studied your response and then looked up the next error message and discovered the importance of the "static method" located at http://www.vijaymukhi.com/documents/books/csbasics/chap3.htm[^] .
Here's the top part of my "extension.cs" file that I created after following your instructions:
namespace myclubv2<br />
{<br />
class extension<br />
{<br />
public string getYMDHMS()<br />
{<br />
string YMDHMS;<br />
YMDHMS = Convert.ToString(DateTime.Now.Year);<br />
<br />
string sMonth = "";<br />
int Month = DateTime.Now.Month;<br />
if (Month < 10)<br />
{<br />
sMonth = "0";<br />
sMonth += Convert.ToString(DateTime.Now.Month);<br />
}<br />
else
and my "mainform.cs" file:
namespace myclubv2<br />
{<br />
public partial class MainForm : Form<br />
{<br />
public MainForm()<br />
{<br />
InitializeComponent();<br />
extension a;<br />
a = new extension();<br />
string ext = (string) a.getYMDHMS();<br />
MessageBox.Show("YMDHmS is " + ext);<br />
}<br />
<br />
...........<br />
}
Now - the above works but I also note that making the namespace AND the class the same in both files I can do away with the following :
<br />
extension a;<br />
a = new extension();<br />
string ext = (string) a.getYMDHMS();<br />
and just use getYMDHMS();
in my "mainform.cs" file.
I am not sure I really understand all this and I would certainly like it to be explained in plain simple terms. I understood what you told me (I think ) but whilst this may be all simple to most - to a beginner I believe that it deserves an article by itself.
Thanks for your response.
Warm regards,
Glen Harvy
|
|
|
|
|
Glen Harvy wrote: string ext = (string) a.getYMDHMS();
No need for a cast.
Glen Harvy wrote: but I also note that making the namespace AND the class the same in both files I can do away with the following
So you changed the extension class to this?
namespace myclubv2
{
public class MainForm
{
public string getYMDHMS()
{
}
}
}
And in your mainform.cs file, you have something like this?
namespace myclubv2
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
string ext = (string) a.getYMDHMS();
MessageBox.Show("YMDHmS is " + ext);
}
}
}
Glen Harvy wrote: I am not sure I really understand all this and I would certainly like it to be explained in plain simple terms.
Note the "partial" keyword above in the class declaration. Declaring a class as partial allows you to split its declaration across several code files. This helps segragate parts of a class so that a single code file doesn't become so large as to be unmanageable.
For example, when Visual Studio generates code for a Form class, it seperates the code for initializing the controls on the Form in a second code file. This initialization code can be quite verbose, and it helps to have it in its own code file instead of poluting the one in which you'll be writing your own code.
So since Visual Studio declared the MainForm class as partial, and since you changed the name of your extension class to MainForm, the code that was in the extension class is now considered part of the MainForm class. So you can call the getYMDHMS method directly from MainForm.
|
|
|
|
|
Leslie Sanford wrote: Glen Harvy wrote:
string ext = (string) a.getYMDHMS();
No need for a cast.
That was a hangover from trying to find the problem
All makes sense now - thanks once again.
Cheers,
Glen Harvy
|
|
|
|
|
Hello
If you're trying to break a single class over multiple files, I should remind you that you should declare it as partial . Otherwise using the same namespace would work fine.
Regards
|
|
|
|
|
Hey guys,
I am writing a little two way chat program for fun and I am trying to get an error provider to validate the nickname text field. I have the nickname text field and login button set up within the same group box. Whenever the user clicks the "Logon" button I want to check to see if the nickname textbox is empty. If it is I want to set the error handler. Here is my code:
private void btnLogon_Validating(object sender, CancelEventArgs e)
{
if (tboxNickname.Text == "")
{
mainErrorProvider.SetError(tboxNickname, "No nickname entered.");
e.Cancel = true;
if (tboxNickname.CanFocus)
tboxNickname.Focus();
}
else
{
mainErrorProvider.SetError(tboxNickname, "");
}
}
So my problem is this. When i click the button nothing happens, until i click something on the form that is outside of the group box containing the button and text field. Can anyone tell me what is going on? Thanks in advance.
-- modified at 19:26 Tuesday 8th August, 2006
|
|
|
|
|
Put your code in btnLogon_Click method.
Remove e.Cancel = true;
btnLogon_Validating will be called if the button lost his focus.
That's the same with tboxNickname_Validating, only called if textbox lost focus.
Then use put e.Cancel = true in Form_Closing.
|
|
|
|
|
Hey all,
I'm looking for a color deviation algorithm.
I have a bitmap with a drawing and a background.
My goal is to identify all pixels matching the color of the background, and make them disappear.
My code is working fine, except for one little annoying thing...
There are some pixels (usually near the drawing edges) which are only a bit different in color from the "transparent" color.
My function gets 3 arguments: a bitmap, a transparency key, and a deviation number.
I use the following color comparison:
if ((Math.Abs(p[0] - b) + Math.Abs(p[1] - g) + Math.Abs(p[2] - r)) / 3 <= Deviation) I calculate the avg value of the differences in RGB, and compare it to my deviation parameter.
The above is an improvisation of mine, as you can probably guess.
It works for most of the pixels that I want to erase.
I can tell there's a better way (the right way ) to do this, as I'm not an expert on the image processing subject (YET ).
Soooo, anyway... I tried google, codeproject, and others, but I didn't really had a lead as for what to look for... I've tried stuff like: "Color deviation algorithm", "Pixel comparison algorithm", etc.
Could you please link me to an article / algorithm on the matter?
The right keywords I should search with would be good too.
Thanks in advance,
Shy.
|
|
|
|
|
I've had a look at the (many) Explorer bar controls available on CP, and very good they are too.
However, how do folks typically handle the right (or content) pane in such applications? Take Windows Explorer as a good example - when you select options in the Explorer Bar pane, the content pane changes and not always to the same type of pane as the previous one. Now I know I could achieve this by using layered panels, but I could see this getting pretty messy.
So my question is, how would you folks implement an application like this?
Cheers,
Martin.
|
|
|
|
|
Say I have custom class foo. I also have a class bar that inherits from foo. I want a method that returns an instance of foo and then want to cast it to bar. How can I do this? I am working with C# 2.0. This is how I imagine it working, and it compiles this way, but I get a runtime error that bar cannot be converted into foo.
public class foo
{
public string someVariable;
}
public class bar : foo
{
public string someotherVariable;
}
public static foo SomeFunction()
{
foo returnVal = new foo();
return foo;
}
public static void AnotherFunction()
{
bar barVar = (bar) SomeFunction();
}
I am almost positive that this can be done, but I can't seem to remember how to do it. I don't want to pass in some kind of reference param or Type.
|
|
|
|
|
You can't cast a foo to a bar when you never created a bar
new foo(); creates a foo not a bar so you can't cast it to a bar.
led mike
|
|
|
|
|
What you've set your code up to do is the ability to cast a bar to a foo; but you can't cast a foo to a bar unless it was already a bar to begin with that you had previously cast as a foo.
|
|
|
|
|
Any ideas of how to do something along these lines? In this scenario, foo holds a bunch of variables used in as results from some operations. I have several super classes that inherit foo that have variables that are specific output for that operation.
As an example, say foo holds a return code and input parameters for calling a Process object. bar has a variable that is assigned later on in the calling method. Another class that also inherits from foo has another unrelated variable that is also set later on by the calling function. Basically, I am trying to write a method that calls the Process object and then returns a base type of foo and then I want to be able to assign the variables that are specific to the superclasses without writing a Convert function.
Seems like there is a fairly easy way to do this, but I keep drawing blanks.
|
|
|
|
|
So inside Foo make a method, lets call it FillFoo(), you make this public and then you can now call it from anything that inherits from Foo. This function however will only fill the values you want to put in Foo. The values for bar and other derived objects can be filled with their own methods contained in their respective objects, such as FillBar(), etc...
I think thats sort of what you are trying to do...
|
|
|
|
|
Yeah, that is basically what I ended up doing. Instead of a method though I made a new protected constructor for foo that takes an instance of foo as a param. I then created a new constructor on bar that takes foo as a param and just pass it down the chain. Kinda silly, but it works. I get why .NET doesn't allow you to do what I was trying originally, but it would be nice if you could cast up the inheritance chain (foo can be cast into bar) as well as down (bar can be cast into foo).
Thanks for pointing me down the right path.
-- modified at 20:24 Tuesday 8th August, 2006
|
|
|
|
|
Can somebody tell me how to change column headers in an asp.net datagrid?
Can I use DataGridTableStyle in asp.net. how can I get my column headers to change programatically?
|
|
|
|
|
What exactly you want to do in datagrid header?
BTW this you better can put in the asp.net forum.
Best Regards,
Apurva Kaushal
|
|
|
|