|
Where are my manners? I have forgotten to thank everyone for the responses. It has been awsome being able to get feedback and bounce ideas off you guys. Thank you very much.
|
|
|
|
|
Jim,
You may want to post some simple examples of what you are trying to do, as its hard to give ideas with nothing to go on.
Im 99% sure whatever your problem is can be solved with a decent object model, but I cant be too specific without knowing whhat exactly you're trying to achieve.
|
|
|
|
|
Could somebody kindly give me the code for setting the data to the clipboard for the location point of a control and then retrieving it from the clipboard? The code for the control would be done using ((Control)sender).Location as the data point and it would contain the X parameter (ie X=100 for example) and the Y parameter for the point (ie Y=100 for example). Thus the whole amount that should be written to the clipboard is {X=100, Y=100} which is stored there as a System.Windows.Forms.DataObject. What is the code to write the location of the control using ((Control)sender).Location and retrieving it in another event handler?
New_Phoenix
|
|
|
|
|
The following code example will show you how to use the Clipboard class and place values into and out of it.
private void button1_Click(object sender, System.EventArgs e)
{
Point pt = new Point(100, 100);
Clipboard.SetDataObject(pt, true);
}
private void button2_Click(object sender, System.EventArgs e)
{
IDataObject obj = Clipboard.GetDataObject();
if(obj.GetDataPresent(typeof(Point)))
{
Point pt = (Point)obj.GetData(typeof(Point));
MessageBox.Show(string.Format("X:{0} Y:{1}",
pt.X.ToString(), pt.Y.ToString()));
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick Parker:
I just wanted to thank you. Your code worked great.
I do have two more questions to ask, though. Is it possible to create two clipboard objects with chains of data, one to contain the one set of points and the second to contain a second set of points? I would also then need to be able to add to and remove from those chains and thereby move the next element up the chain in the clipboard.
Second, how could I go about parenting one control to another control? For example, I have one control, and I would like to be able to join two controls together so that they could move together. I know that it would be something involving: ctrl.Controls.Contains(control). That is, I would need at some point to ask the control:
if (ctrl.HasChildren)
{
}
How do I join one control to another control so that I could later check to see if it has any children or whether it is a parent of other controls?
Thanks again ! ! !
|
|
|
|
|
Nick:
Here is some sample representation of the code that I need your assistance with regards to control parenting. The controls that are created programmatically default to a parent of the form's name. I would like to set the parent to control number 3 to control numebr 1.
<br />
for (i = 1; i < 3; i++)<br />
{<br />
Control ctrl = new Control()<br />
<br />
ctrlHold = PositionControl(ctrlName, i, loc_x ....) <br />
<br />
<br />
:confused::confused::confused:<br />
if (i == 3)<br />
{<br />
ctrl.Controls.Add(ctrl ??????? how would it know control 2 ???)<br />
}<br />
}<br />
|
|
|
|
|
Hi.
Somebody know how to obtain serial number of devices (video cards, motherboard, hard disk, network card, floppy, sound card, processor etc).
Please I need this information
I tried using WMI, but only I got serial number of hard disk
thanks.
Gussano
|
|
|
|
|
WMI will only work if the manufacturer of the device supplys a WMI provider that will supply this information. Most of the time, the manufacturers DON'T supply this information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave.
Thanks for your information.
But now the question is:
How to get the serial number (or better all manufacturer information) of a device?
Best regards.
Gussano
|
|
|
|
|
About the only things your going to get a serial number off of are the system (motherboard) and the hard drives. Manufacturers of video cards, CD drives, controllers and other peripherals usually don't supply this information in any way, shape, or form. There is no one Win32 API function that will return this information either.
If you use CIMStudio to search around WMI, you'll find that if you try to get the Manufacturer field off of, say, a CD drive, you'll get back "(Standard CD-ROM drives)". There is no SerialNumber field.
If you look for the VideoController, you'll find that there is no Manufacturer field, nor a SerialNumber field. The Manufacturer is listed under the AdapterCompatibility field. Doesn't make much sense, does it?
In short, you're looking to get information that is not supplied anywhere...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a windows form with a datagrid on it. When the user clicks a button 'Retrieve', it populates the datagrid with the appropriate data. A couple of the columns in this datagrid contain comboboxes in them.
I am using a class similar to the one in the article "DataGrid Zen Novice" to implement my comboboxes.
The problem I'm having is trying to figure out how to populate the values of one combobox, when a new item is chosen from another box. This has to be done for individual rows in the datagrid.
For example:
In my datagrid there is a column for item numbers, and a column for warehouses. If a new item number is chosen from the combobox in row three of the datagrid, the warehouses combobox in row three needs to be re-populated with the appropriate warehouses for this item.
Any ideas on the best way to do this?
Thanks in advance!
nadandjade
|
|
|
|
|
If I have a single WebBrowser control (either the managed wrapper in 2.0 or the ActiveX instance), is there anyway I can force it to draw to the screen multiple times without creating multiple instances of the control? Basically what I want to do is:
-------------------
<draw some html in here>
-------------------
<draw other html here>
-------------------
and so on. I know I can do this with the RichTextBox via P/Invoke (MSDN article on that here[^]), but that same P/Invoke trick doesn't seem to work on the WebBrowser control.
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
|
Hi everybody,
it seems to be so simple but ...
I want to store the contents of a multiline textbox into SQL-Server or MSDE.
Using the ntext or text field of the databases does not show the expected results.
The Database truncates all text comming from multiline textbox after a space or CRLF charakter.
The DataSet in memory stores the correct contents but the Database itself truncates the rest.
Is it because the multiline textfield is an array of string[] ?
do I have to iterate over the string field ?
Why does the DataSet does it right but the Database not ?
Thanks in advance
fracalifa
|
|
|
|
|
That depends on how your sending the information to the database. Are you using a parameterized query? What does your code that sends the info to the database look like? On top of that, you must store a single string, not an array of them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That' the code I am using for
private void data_update()
{
SqlDataAdapter adapter = new SqlDataAdapter();
string upd_CommandString = "UPDATE database_name SET textboxA=@textboxA WHERE id = " + id.ToString();
SqlCommand updateCommand = new SqlCommand();
updateCommand.CommandText = upd_CommandString;
updateCommand.Connection = conn;
adapter.UpdateCommand = updateCommand;
updateCommand.Parameters.Add(new SqlParameter("@textboxA", SqlDbType.NText,16,"textboxA"));
DRow.BeginEdit();
...
...
DRow["textboxA"]= this.txt_Multiline_Textbox.Text; // assign the multiline TB to DataRow object
...
...
DRow.EndEdit();
DB.open(ref conn); // connect Database
adapter.Update(Ds,"database_name");
DB.close(); // close Database
}
// The Database query simply looks like --> SELECT * FROM database_name WHERE id = 123
Whithin the Ds everything is fine, but not in the database field.
Using the database fieldtype NVarChar,4000 instead - everything looks fine -
Where is the fault ?
Thanks
fracalifa
|
|
|
|
|
The problem appears to be this line:
updateCommand.Parameters.Add(new SqlParameter("@textboxA", SqlDbType.NText,16,"textboxA"));
Your telling it that the parameter is a SQL NText field that is 16 bytes long. The type and size value you give it must match the definitions in your database table. If not, you run into screwy problems like this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello All,
I have a form that has 4 textboxes on it and a button. Initially the button is disabled but as soon as someone types/changes text in one of the text boxes I would like to enable the button. How can I detect changes in a text box ? Do I need to watch out for changes in each individual textbox or is it possible for the form to notify me that one of the textboxes changed ? Thanks in advance...
-Peter
|
|
|
|
|
Hi Peter,
I think the simplest solution is to add one EventHandler for the KeyPress-Event for all 4 textboxes.
For example the eventhandler can look like this:
<br />
private void txtTextBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) {<br />
<br />
}<br />
To make sure that all 4 Textboxes calls this handler, simply click at the textbox (Forms-Designer in VS.NET) and select the flash-symbol from the properties page. There you have an entry called KeyPress and there you can select the method above.
Now you can call a method in this handler to verify the content of the textbox and do what you want with the button.
I hope this helps you.
Sebastian
P.S: Sorry for grammar and spelling...
|
|
|
|
|
To add the posting of Mr. SeMartens. If you want to do some specific task in the keyPress event of a perticular textBox , You can easily do the same. Below example illustrate the same.
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxesKeyPress);
this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxesKeyPress);
this.textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxesKeyPress);
this.textBox4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxesKeyPress);
private void TextBoxesKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(sender == this.textBox1)
{
}
else if(sender == this.textBox2)
{
}
else if(sender == this.textBox3)
{
}
else if(sender == this.textBox4)
{
}
}
Do revert back whether it could solve your purpose or not
|
|
|
|
|
Hello guys,
This should have been simple, but im pretty stuck here.
I have an simple XML file where i want to change the content of the file. The file is as follows
config.xml
<Config>
<ReportServer>0</ReportServer>
<LastReportDate>20041214</LastReportDate>
</Config>
is there a simple way to change the content of the elements fx. <ReportServer> to a 1 instead of a 0 ??
Cheers
Ronni
|
|
|
|
|
yes there is simple way, use System.Xml.XmlDocument . Why don't you try XML forums?
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Here's some sample code for you:
using System;
using System.Xml;
class Class1
{
static void Main(string[] args)
{
string xmlpiece = @"<Config>
<ReportServer>0</ReportServer>
<LastReportDate>20041214</LastReportDate>
</Config>
";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlpiece);
XmlNode node = doc.SelectSingleNode("/Config/ReportServer");
node.InnerText = "1";
Console.WriteLine(doc.OuterXml);
}
}
Yes, even I am blogging now!
|
|
|
|
|
Why my program process a file in 6 minute and if I reprocess same file, it take 6 seconds. I am runing on xp operating system.
Thank you
|
|
|
|
|
"process" can mean anything! What, EXACTLY, are you talking about?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|