|
Hallo!!!
So once again I have a problem....
This time i'm having trouble passing a reference of a form to an object, on the load_form event.
But this just gives me a blank reference....
How can I go around this?
|
|
|
|
|
I'm having trouble understanding what you're trying to do. Please post some code. And by blank do you mean null reference or do you have a watched variable that is showing up blank?
|
|
|
|
|
Well basicly what i've been doing is:
private void Form1_Load(object sender, System.EventArgs e)
{
//initiating a class (declared earlier=
defaultCls = new defaultClass(pictureBox1, form1.aktiveform);
}
//(only an example)
public class default
//construktor
public default(pictureBox pB, form frm)
{
// trying to use the frm reference...
}
Error message:
An unhandled exception of type 'System.NullReferenceException' occurred in CopyImage.exe
Additional information: Object reference not set to an instance of an object.
Well this must mean that the Form1 reference isn't set at this time, musn't it???
It works fine if I do the same, on f.x. a keypress event....
What I really was wondering about is if theres an event, which occurs after load complete.
f.x. OnLoadComplete(), or something like that????
|
|
|
|
|
I re-created what you gave me the best I could and it worked. I could not get any null reference exceptions.
The only thing I don't get is why your passing ActiveForm (assuming thats what you mean by "aktiveform") which may or may not actually be the form you want to reference.
|
|
|
|
|
So you are able to send a reference to an object (done when the OnLoad event occurs), and then use it in the object...
To be more precise, I tried to get the window location by saying:
//the frm = reference of Form1.AktiveForm
frmX = frm.Location.X
But that just throws an exception...
Ok so the problem could be that I'm sending the Form1.AktiveForm, you say... Yes that sound very likely because noone says that the form is Aktive (or in focus) at this time....
Then you said that you can't se the logic in me sending Form1.AktiveForm.... What shoudl I be sending???
If I try just to send Form1, the debugger says soemthing about a variable was expected????
...... so any ideas??? >
|
|
|
|
|
Heh....ehh... ups.... all I had to do was send a "this" pointer instead.... dooh.
Well I'm still new at c#, so I have an excuse
Anyway, thanks!!!
|
|
|
|
|
Hi,
I have a main window which is a MdiParent and to which i pop up a couple of other windows (on some event) as mdiChild using the show() method. I want each child window to appear at a particular position for which i use DockStyle properties.
But the new window which opens up resizes itself to the height or width of the original window depending on the dockstyle. I want the size of the mdichild form to remain as it is. What property should i set for this.
Also, In case there are more than one window which pops up,when i change the control from one window to another the position of the window changes. How to avoid this??
Thanks
Sripriya
|
|
|
|
|
simply setting the Location property doesn't work?
:wq
|
|
|
|
|
1.Choose "Microsoft OLE DB Provider for ODBC Drivers"
2.Choose "Use data source name" and select a alias from drop list.( The alias has no password)
3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".
Thank you for your help!
I'm amumu, and you?
|
|
|
|
|
You have three options:
- If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
- If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
- If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;
|
|
|
|
|
Thank you.
But I think the oleDbConnection should work properly when I do the steps as above, why does it reports error?
I'm amumu, and you?
|
|
|
|
|
The objects in System.Data.OleDb do not support ODBC connections, so you can't use the OLE DB Provider for ODBC. You have to use the ODBC .Net Provider to access an ODBC data source.
|
|
|
|
|
if u just wanna use access like me, just use a JET OLE DB connection. eg:
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
hope it helps
|
|
|
|
|
|
Where can see the information?
I'm amumu, and you?
|
|
|
|
|
Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
string query = "SELECT * FROM TABLE WHERE etc etc";
OleDbCommand myCommand = new OleDbCommand(query, accessConn);
OleDbDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
string datain = myReader.GetString(0);
}
DataTable dt = new DataTable();
OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
sda.Fill(dt);
Hope this helps
|
|
|
|
|
Thank you
This method can work properly.
I'm amumu, and you?
|
|
|
|
|
Hello once again my fellow CPains!
I have one quick question I would like to ask, what would be the best way to determine the amount of items in an array which would allow me to store that amount into an integer?
|
|
|
|
|
brian1415 wrote:
my fellow CPains!
I don't think you will get an answer if you are that rude to the people.
brian1415 wrote:
what would be the best way to determine the amount of items in an array which would allow me to store that amount into an integer?
Now that is really confusing question
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio about posting in the right forum. The Lounge - June 23, 2002
|
|
|
|
|
I am sorry that was a very foolish question and I promptly figured out how I would do it. Sorry for wasting you time.
|
|
|
|
|
So what was the question and what is the answer?
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio about posting in the right forum. The Lounge - June 23, 2002
|
|
|
|
|
2 replies and not even a single attempt to answer the guy.
BAD DOG, DOWN BOY
depending if u have an array or a collection, the 'Length' or 'Count' property will have the answer u looking for.
|
|
|
|
|
Use the Length property of the array; all arrays are derived from the System.Array class; so that should be your reference for any array questions (such as dealing with multi-dimension arrays).
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Sorry everyone, What I was attempting to do was add items of an array to a listbox. My first thought was to use a for statement to add each item to the listbox and for that I would have needed the number of items in an array. After doing some looking I found listBox.Items.AddRange() which automaticly adds each item of the array to the listbox. Thank you for your reply Tom, and sorry Ricku for confusing you.
|
|
|
|
|
http://www.codeproject.com/cs/miscctrl/cutebutton.asp
I want to implement the angle variable for the control.
The angle variable is responsible for the shadow angle painted on the button.
The LinearGradientBrush requires a float as angle.
The property page of the control at design time expects a Single.
Thusly...
public int angle
{
get{return (int)m_angle;}
set{m_angle = (float)angle; Invalidate();}
}
...
Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle,
c1, c2, m_angle);
...
No effect. Changing the angle at design time will revert the angle back to it's original zero, instantly after loss of focus.
How would you implement the angle variable for this control?
Help please!!!
Coding is a family business
|
|
|
|