|
Glad you're up and running!
/ravi
|
|
|
|
|
Wrong. The problem is he's trying to access the non-static method on the Form1 class instead of an instance of Form1.
The class trying to access an instance of Form1 can only get a reference to the instance of Form1 if it creates the form instance, or the form gives the using class an instance of itself.
The following will work, but it's not a very wise design decision to allow processing classes to has instances of your Form. Better to have you working classes just do work with data and return values that your UI can use.
namespace RouletteV1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void btn1_Click(object sender, EventArgs e) {
NumberAttributes.Load(this, 1);
}
public void SetFormData() {
textBox1.Text = "Hello";
}
}
public static class NumberAttributes {
public void Load(Form1 form, short Number) {
NumberProcessing.UpdateNumArray(form);
}
}
public static class NumberProcessing {
public void UpdateNumArray(Form1 form) {
form.SetFormData();
}
}
}
-- modified at 11:46 Monday 24th July, 2006
Whoever voted this message down can kiss my hairy white ass, unless they'd like to actually post something to refute it.
|
|
|
|
|
Thanks a lot for that, you were exactly right! I have slightly altered my code to cut down on the form reference passing. However when I try compling it it throws up an error - Compiler Error CS0120 - Error Message
"An object reference is required for the nonstatic field, method, or property 'member' " and refers to line
NumberProcessing.UpdateNumArray(this);
I am guessing there is a problem with the "this" value?
Any suggestions what is wrong??? Code is below.
namespace RouletteV1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
} <br />
<br />
private void btn1_Click(object sender, EventArgs e)<br />
{<br />
NumberAttributes.Load(1);<br />
NumberProcessing.UpdateNumArray(this);<br />
}<br />
<br />
public void SetFormData()<br />
{<br />
tboxNumArray.Text = "Hello";<br />
} <br />
<br />
public class NumberProcessing<br />
{<br />
<br />
public void UpdateNumArray(Form1 form)<br />
{<br />
form.SetFormData(); <br />
} <br />
}<br />
}
Thanks in advance for your help
Haz
|
|
|
|
|
Forget that I had missed off the static keyword for a method in one of the static classes. Only just realised that all static classes should have static members.
Thanks again for your help
Haz
|
|
|
|
|
well I just wanted to know, Can u place another datagrid inside one datagrid. I'm talking abt System.Windows.Forms here.
the other thing is that I wanted to do that bcz I wanted to display and receive data for a sales form. It has dat comming from 5 related tables. I had this idea but can any one of u give me some better idea of making a v user friendly interface. the tables are Prodline, prodmodel, Bill, purchase and customer.
Its basically for a coomputer shop. Can Anyone help?
I'm working in .net 1.1 mind u
-- modified at 8:40 Saturday 22nd July, 2006
|
|
|
|
|
Why do you need "nested datagrids" at the first place ? Believe me, users hates anything that doesn't not comply with their expectations and giving them that kind of interface won't take you to the right place.
Instead of creating a mess from the five tables on the one form I would consider adding a buttons/hyperlinks inside of the data rows. Clicking on particular button user navigates to the new form (or opens a e.g. combobox) with the data from linked table (prodline, prodmodel, etc).
|
|
|
|
|
Many thanks. I was also thinking on almost teh same lines but can u tell me if we can make combo boxed inside of datagrid column.
|
|
|
|
|
To put a combo box into a datagrid you should specify that particular columns (which
you'd like to be combobox-enabled) should be created using the DataGridComboBoxColumnStyle.
|
|
|
|
|
well I'm working in .Net version 1.1 which I think doesnt have anything such as DataGridComboBoxColumnStyle so what can I do now...
|
|
|
|
|
Hi,
I want to put the value of a column from a row in a datatable where I know the row number ie
string CName = [row=1, column=Names in datatable=dtClubs]
What goes into the [ .....] part?
TIA
Glen Harvy
|
|
|
|
|
DataSet dsTemp = new DataSet(); <br />
DataTable Tables = new DataTable(); <br />
dsTemp.Tables.Add(Tables);<br />
string data = dsTemp.Tables[0].Rows[0][0].ToString();
|
|
|
|
|
|
DataSet dsTemp = new DataSet();
DataTable dtMyClub= new DataTable();
dsTemp.Tables.Add(dtMyClub);
string data = dsTemp.Tables[0].Rows[0]["ClubName"].ToString();
//result
// string data = "North Ponly Club"
or can u set here ur piece code to see what are u want to do
-- modified at 9:06 Saturday 22nd July, 2006
|
|
|
|
|
Thanks for the help.
I need to work out a couple of other things as well.
Glen Harvy
|
|
|
|
|
Hi,
I am facing an odd problem. I have library class that fills up binary data in a string that is passed by ref to one of its function. The problem is when i convert the data into byte[] using the function System.Text.Encoding.Uncode.GetBytes();
I dont get the actual binary data which the library program has given to me.
I checked the length of the string before converting it into byte and it was the same as was sent by the library program. But when i convert it into byte[], not only the size is different but also the data is changed. I think some of the characters in the data are not valid Unicode data.
Is there any othe method which can give me the raw byte[] without applying any encoding scheme.
Like: byte[] GetByteData(string strData);
Regards
-Mursil
Take a very good care of Yourself.
Sayed Ahmad Mursil
|
|
|
|
|
Hello
There are more encoders than just Unicode. Did you try them?? Including Encoding.Default
You wouldn't want to put your string in a for loop and read it byte by byte, would you?
Regards
|
|
|
|
|
I have tried this method also.
But Encoding.Default basically returns Unicode encoding reference by default.
so it doesnot server the purpose.
Is there any open source library for other encoders.?
i.e which doesnt encode any thing. Just give me the exact byte[] stored in the string.???
Take a very good care of Yourself.
Sayed Ahmad Mursil
|
|
|
|
|
Hello
How would anybody know how your library is storing the bytes? I mean if you have byte sequence 1,2,3,4 It culd be stored as:
01, 02, 03, 04
or
01, 00, 02, 00, 03, 00, 04, 00
Or for whatever it's worth it, it could be comma delimited (Dec for comma is 39):
01, 39, 02, 39, 03, 39, 04, 39
It depends mainly on your library, and how it fills the string.
Regards
|
|
|
|
|
You are absolutely right.
Actually the library program is a COM program. It captures an image and then send the image data to by filling the binary image data in the ref string. I am getting the complete data but when i try to get the bytes out of the string, it is not the same as those transmitted by the library program.
( I have already done logging at both ends to compare the binary data. Also i have a lmitation that i cannot change the interface of my library program).
I am sure that the raw image data doesnot follow any of the encoding shceme you have mentioned. The last option for me is to encode the data in the library before sending it to the main application. But this is the last thing i wana do bcz it will almost doubles the size of the data.
So I am looking for an alternative solution in this regard that can work without
encoding the image.
Thanx for your time and support...
Regards..
|
|
|
|
|
Hello
Mursil wrote: last option for me is to encode the data in the library before sending it to the main application
Wait a minute!! Should I understand from this that you wrote that library?? If so, why not passing the data as a bytes array from the begining?
Mursil wrote: It captures an image and then send the image data to by filling the binary image data in the ref string
If it's a 3rd party library and this is what it does. Why can't I see anything special about it?? I mean you can capture an image from the screen as easy as one method: Graphics.CopyFromScreen() , if you are capturing from a camera or a scanner, then maybe the problem is in the library?? How did you know that the data sent by the library is valid?
Regards
|
|
|
|
|
Hi,
Just wanted to ask if any body knows how to add context menu handlers for your custom application, for example, if my application is registered with .abc then there are some verbs that I can set which will work on .abc file. What I am asking is that how to add context menus when the user clicks to any file extension, those menus should appear and then I can set the command parameter for those menus in registry to my own custom application... can any body help
Thanks in advance...
regards,
Waqas
|
|
|
|
|
With a .Net deployment project, you can add new file types to the registry and specify their actions and what applications are invoked when used. But if you're looking to create your own context menu, that's beyond the scope of .Net, and I'm not sure what all you might have to do with the registry to accomplish that.
|
|
|
|
|
hai all.
how to check whether a system is there in a particular network using C#.net... or how can i access a system in the netwaork using c#.
Regards
|
|
|
|
|
what you want to access.
1. Any DB on other machine
2. Any web Service on other machine
3. Any Window service
4. Any remoting Object
5. Serialization
6. Operate other system
7. Extract folder information
8. Display like remote desktop
9. There are many more to go.. what you exactly wants ?
Rizwan Bashir
|
|
|
|
|
hai..
i just want to extract shared folder information of remote system...
Regards
|
|
|
|