473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Can't initialize .Text property in constructor

Hi,

I have a textbox on a form. When I assign a string to the .Text
property while in my form's constructor, the program just hangs
indefinitely.
Alternatively, if I assign the string to the form's .Text property, it
works fine.

this code hangs (never returns from 3rd line):

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
txtMessage.Text = "XRY CONNECTED";
}

this code works fine:

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
this.Text = "XRY CONNECTED";
}

Any ideas?

Nov 17 '05 #1
2 1815
Your two examples are doing two different things.

The first one attempts to set the Text property of a TexBox (txtMessage).

The second one attempts to set the Text property of the Form class itself
(this).
Hope this helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"no*****@yahoo.com" wrote:
Hi,

I have a textbox on a form. When I assign a string to the .Text
property while in my form's constructor, the program just hangs
indefinitely.
Alternatively, if I assign the string to the form's .Text property, it
works fine.

this code hangs (never returns from 3rd line):

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
txtMessage.Text = "XRY CONNECTED";
}

this code works fine:

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
this.Text = "XRY CONNECTED";
}

Any ideas?

Nov 17 '05 #2
P.S.
Try this:
public frmSubSystemInterface()
{
InitializeComponent();
try{
if ( CDLIsConnected(9) == 1 ) // external dll call
txtMessage.Text = "XRY CONNECTED";
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message+ex.S tackTrace);
}
}
-- and put a breakpoint on the "System.Diagnostics.... line.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"no*****@yahoo.com" wrote:
Hi,

I have a textbox on a form. When I assign a string to the .Text
property while in my form's constructor, the program just hangs
indefinitely.
Alternatively, if I assign the string to the form's .Text property, it
works fine.

this code hangs (never returns from 3rd line):

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
txtMessage.Text = "XRY CONNECTED";
}

this code works fine:

public frmSubSystemInterface()
{
InitializeComponent();

if ( CDLIsConnected(9) == 1 ) // external dll call
this.Text = "XRY CONNECTED";
}

Any ideas?

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Henry | last post by:
I was trying to derive a class from System.Windows.Forms.ComboBox. My goal was to create a class that loaded its own data. I did not want to create too many objects, so I tried to share a Database...
2
by: norvinl | last post by:
Hi, I have a textbox on a form. When I assign a string to the .Text property while in my form's constructor, the program just hangs indefinitely. Alternatively, if I assign the string to the...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
5
by: Just Me | last post by:
Given a button name Btn_5 and Index=5 I want to do something like dim zz as string = Btn_??Index??.Text or given an array of buttons, do:
12
by: NewToCPP | last post by:
does the default constructor initialize values? I have a class as defined below: class A { int i; char c; int * iPtr;
15
by: thinktwice | last post by:
char a = { 0 } is it ok?
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
14
by: 2005 | last post by:
If a Constructor can be used to initialize, when is memory is allocated / say the "new" operator etc? Thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.