|
Hi everyone,now I have a winform Form1,in Form1,there is a TextBox1,and its Text is "abcd".
In the other project,I want to get the Text of TextBox1,as below:
Assembly assembly = Assembly.LoadFrom(@"ClassLibrary1.dll");
Type[] types = assembly.GetTypes();
FieldInfo[] fis;
System.Windows.Forms.TextBox tb;
for (int i = 0; i < types.Length; i++)
{
fis = types[i].GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
for (int j = 0; j < fis.Length; j++)
{
if (fis[j].FieldType == typeof(System.Windows.Forms.TextBox))
{
tb = fis[j].GetValue(Activator.CreateInstance(types[i]))as System.Windows.Forms.TextBox;
Console.WriteLine(tb.Text);
}
}
}
Console.Read();
But I have to create a instance "Activator.CreateInstance(types[i]))".Are there any ways that I can get the Text without create a Form1 instance?
Anyone who can help it would be appreciated.
|
|
|
|
|
Morven Huang wrote: Are there any ways that I can get the Text without create a Form1 instance?
Since the textbox is a member of Form1, you need to instantiate Form1 for getting access to text box.
|
|
|
|
|
That would be like asking for the colour of a car that doesn't exist. You know that cars have colours - but you the colour doesn't exist without the car.
|
|
|
|
|
|
Hai
Me with C#.net I want to make a text box to accept only numbers and decimal points(decimal point only once), so I tried to make a user control and is working fine except one problem. If if select all the data in the text box and try to enter a new value decimal point will not accept until I press the backspace. My user control code is a follows
string i;
int f;
public string Text
{
get
{
return NMTextBox.Text;
}
set
{
NMTextBox.Text = value;
}
}
private void NMTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
string numaric = NMTextBox.Text;
for (int j = 0; j < numaric.Length; j++)
{
char myChar = numaric[j];
}
if (NMTextBox.Text == "")
{
f = 0;
}
if (e.KeyChar.ToString() == ".")
{
++f;
if (f >= 2)
{
e.Handled = true;
}
}
if (i == "8")
{
f = 0;
for (int j = 0; j < numaric.Length - 1; j++)
{
if (numaric[j].ToString() == ".")
{
++f;
}
}
}
if (e.KeyChar.ToString() != "." && Char.IsNumber(e.KeyChar) != true)
{
if (i != "8")
{
e.Handled = true;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, ex.Message.ToString());
}
}
private void NMTextBox_KeyDown(object sender, KeyEventArgs e)
{
i = e.KeyValue.ToString();
}
Thanks & Regards
|
|
|
|
|
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then
'If db.Tables.Item(sTableName).Rows > 0 Then
db.Tables.Item(sTableName).ExportData(objBCPExport)
'End If
Else
Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName
If Trim(sCondition) <> "" Then
sSelectCommand += " WHERE " + sCondition
End If
'Create a temporary view to hold data
Try
db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
Catch
End Try
db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
db.Views.Refresh()
'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP)
'Export data to a file
db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport)
Try
db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
Catch
End Try
End If
|
|
|
|
|
There are lots of tools for this, but I assume no one is perfect. Do it manually.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
First just write in simple english what this code does and then think how to write that in C#
I think that's the simplest method
|
|
|
|
|
To Convert to C# from another Language you must Understand C#
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
How do made xml file that read or write in ?
|
|
|
|
|
Check this link[^]
Regards,
Lev
|
|
|
|
|
There are classes available and by using objects of those classes u can read/write in XML file
google it!
|
|
|
|
|
I want add control to form and then use the event dubleclick for control? help me thanks..
|
|
|
|
|
When u create the object of your control also register the event with it by using += operator
concept of delegates
|
|
|
|
|
Hi All,
does anybody have an idea of how to generate an eqivalent CAML query for the following SQL statement
"select max(IntColm) from Table group by StringColm"
Thanks in advance..
Red October
modified on Tuesday, December 30, 2008 12:06 AM
|
|
|
|
|
what the function to get the name of the node itself ( Request)?
<request num_param="0" bytecount="0">
|
|
|
|
|
hung1984 wrote: what the function to get the name of the node itself ( Request)?
The Name of the node? Could that be what the Name[^] property is for?
|
|
|
|
|
I have 1 xml file :
<myxml>
<common>
<number a="0" des="int">
<number a="1" des="doub">
i want to get value of "a" and "des" node, my code below get wrong?
XmlDocument Reader = new XmlDocument();
Reader.Load("MyXml.xml");
XmlNodeList List = Reader.SelectNodes("/MyXml/common/Number");
foreach (XmlNode node in List)
{
int i = int.Parse(node["a"].InnerText);
des[i]= node["des"].InnerText;
}
thanks
|
|
|
|
|
If you are going to include XML in your post either manually escape the XML characters or check the "Ignore HTML tags in this message (good for code snippets)" box for the post (below the smilies and above the submit button)
If you are using .NET 3.5 there are new and better classes for querying XML.
|
|
|
|
|
If node a and des have attribute called "name" then you can get the value of that attribute by following
foreach (XmlNode node in List)
{
int i = int.Parse(node["a"].Attributes["name"].Value;);
des[i]= node["des"].Attributes["name"].Value;
}
|
|
|
|
|
Hi
I want to do a project where I need to calculate the intersection of the two cubes but I don't now how i can calculate the volume of this intersection. This is the project
Create a small web application that allows a user to enter the dimensions and coordinates of two cubic objects in a 3-dimensional space. Once the information has been entered, the web application should calculate if the two cubes intersect, and if so, what the volume of the shared space is.
Note, the coordinates specify the CENTER of the cube!
Sample Data:
Cube A: Size = 5m x = 10m
y = 10m
z = 0
Cube B: Size = 2m x = 9m
y = 9m
z = 1m
Answer: Do the cubes intersect? What is the volume of the shared space?
|
|
|
|
|
Guys,
I am trying to save the hidden panel contents to an image using GDI+.
I do not want to resize the panel to show all the contents and then save it.
I would like to keep the panel at the default size and save all the hidden contents without scrolling.
Thx.
|
|
|
|
|
Image image = this.panel1.BackgroundImage;
image.Save("1.jpg");
Tan Li
I Love KongFu~
|
|
|
|
|
Thx for the response.
The contents on my panel are custom drawn items. I would to save everything (hidden items as well) to a image file without scrolling or resizing the panel.
|
|
|
|
|
Well, about this, I do not know how to save the graphic objects into a file directly. However, you can save a image through Bitmap. Such as:
Bitmap bitmap = new Bitmap(400,400);
Graphics g = Graphics.FromImage(bitmap);
Pen pen = new Pen(Color.Black);
g.DrawEllipse(pen, new Rectangle(10, 10, 200, 200));
bitmap.Save("test.jpg");
Hope this will help you~
Tan Li
I Love KongFu~
|
|
|
|