|
rzvme wrote: to copy items between 2 listboxes using a drag and drop operation help me out
This Google search[^] comes up with some good stuff. First one is here on CP. Hope this helps you out
|
|
|
|
|
None of the examples I found via googling actually were complete or bug free. Actually getting one to fully work was almost a weeks worth of pain. If I could do it over again, I'd've used a listview since it has more built in drag/drop support. I managed to get a drag/drop demo working with it in under a day with less than a month of language experiance.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
Nish's article code seems to work pretty good. I don't know to what extent the OP is looking for.
|
|
|
|
|
hi
i was create a new instance of thread class and pass to it a method(with 1 parameter) and start then pass it's argument to method by this code :
//my method that get 1 argument
private void ShowWaitForm(string message)<br />
{<br />
Frm_Waiting fw = new Frm_Waiting();<br />
fw.label1.Text = message;<br />
fw.ShowDialog();<br />
}
// error in this line
System.Threading.Thread th = new System.Threading.Thread(this.ShowWaitForm);<br />
th.Start("Please Wait ...");
but the following error show me :
The best overloaded method match for 'System.Threading.Thread.Thread(System.Threading.ThreadStart)' has some invalid arguments
and :
Argument '1': cannot convert from 'method group' to 'System.Threading.ThreadStart'
i was compile and run it without any problem 2 hours ago but now has error,
how to solve my problem ?
|
|
|
|
|
hdv212 wrote: System.Threading.Thread th = new System.Threading.Thread(this.ShowWaitForm);
Change it to
System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(ShowWaitForm));
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
1. You need to use a ParameterizedThreadStart:
System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(this.ShowWaitForm));
This allows your thread to run a Method that takes in a parameter and then start like you have done, but . . .
2. You need to change the interface of ShowWaitForm from
private void ShowWaitForm(string message)
to
private void ShowWaitForm(object message)
The delegate used by the ParameterizedThreadStart object references a function of type void that takes in an object as a parameter. You're giving it a function of type void that takes in a string instead. Once you've gotten this to work just cast the object to a string inside of ShowWaitForm .
|
|
|
|
|
I need to insert a special charater into the RichTextBox onclick a button.
But, if i did something like this:
richtextbox1.Text += "©";
The charater © will get added to towards the end of the richtextbox document, not where the IBeam (or the cursor) is pointing to.
How can i insert simple text at the exact position the Ibeam or the cursor is standing inside the richtextbox1 ?
|
|
|
|
|
I tried this code (onclick insert button)
MessageBox.Show("Top : " + richtextbox1.Cursor.Size.Height);
MessageBox.Show("Left : " + richtextbox1.Cursor.Size.Width);
But this kept giving me:
Top : 24
Left : 24
No matter where the Ibeam/cursor was...
|
|
|
|
|
that's giving you the size of the cursor, which should be apparent from the name. I'm just looking at the intelisence, might the rtb.SelectionStart property be what you want?
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
BRILLIANT!
i had no idea rtb had a variable like that
i used this to test it:
int pos = EditingArea.SelectionStart;
MessageBox.Show("Last Line : " + pos);
It always showed the exact position the IBeam/Cursor was at.
Now here comes my second problem, how do u insert the special char at the rtb.SelectionStart?
|
|
|
|
|
I tried to do something like this:
rtb.SelectionStart = rtb.SelectionStart + rtb.SelectionLength;
rtb.Text += "©";
This still doesn't help. Should i use rtb.Text.Insert(); ?
-- modified at 13:39 Wednesday 25th April, 2007
|
|
|
|
|
I think im almost there
this code always shows the exact position my IBeam/Cursor is standing on
int pos = rtb.SelectionStart + rtb.SelectionLength;
So, i thought i cud use it to insert the special char using the Text.Insert(); method:
rtb.Text.Insert(pos, "©");
Even this isnt working... why is it so hard to set position of text insertion? Im running out of ideas, can someone please help me out here... i did way too many trial and error and i still haven't found any solution yet...
|
|
|
|
|
1 hour wasted and i finally worked it out
this.richTextBox1.SelectedText = "©";
so simple... wish they had some sort of "how-to" document/wiki for each components such as richtextbox
|
|
|
|
|
Hi All,
My C# - VS2005 Application occasionally gives the NullReferenceException when the application is being debugged in Relase mode. It occurs when the program is left idle in debug mode for a long time around 30min.
Any idea why such an error could occur?
Please find the call-stack of the error.
System.Windows.Forms.dll!System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle waitHandle = {System.Threading.ManualResetEvent}) + 0x18 bytes <br />
System.Windows.Forms.dll!System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control caller, System.Delegate method, object[] args, bool synchronous) + 0x36d bytes <br />
System.Windows.Forms.dll!System.Windows.Forms.Control.Invoke(System.Delegate method, object[] args) + 0x48 bytes <br />
System.Windows.Forms.dll!System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback d, object state) + 0x61 bytes <br />
System.dll!Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.Invoke(bool checkFinalization = true, object[] args = {Dimensions:[2]}) + 0x68 bytes <br />
System.dll!Microsoft.Win32.SystemEvents.RaiseEvent(bool checkFinalization = true, object key = {object}, object[] args = {Dimensions:[2]}) + 0x106 bytes <br />
System.dll!Microsoft.Win32.SystemEvents.OnUserPreferenceChanging(int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x6f bytes <br />
System.dll!Microsoft.Win32.SystemEvents.WindowProc(System.IntPtr hWnd = 591970, int msg = 8218, System.IntPtr wParam = 47, System.IntPtr lParam = 2201016) + 0x288 bytes
Any help will be great.
Arti Gujare
|
|
|
|
|
Can anyone tell me if there is a way in C# to do a reverse find?
I have an address that i am parsing say:
124 Modal Street SpringField MO 11222
I start from the back and get the zip and state cause that is more common.
From there, i would just like to grab the city by getting a start index of the space before "SpringField". Can i do that from reverse like this?
|
|
|
|
|
You might want to consider using Regular Expressions to parse things like addresses
led mike
|
|
|
|
|
Use the LastIndexOf method on the string. You can use it to search from the end of the string, or from a specific character index, towards the beginning of the string.
---
single minded; short sighted; long gone;
|
|
|
|
|
You could use the Split method on the string. It would pass back an array of strings. Then you can look at the last value in the array for zipcode etc.
Ben
|
|
|
|
|
hi.. i'm writing a prog to send and write data to a clock via a serial port. i hv some errors on the code.. can someone look at my code and help me solve the prob? this is the errors i got...
Error1: A namespace does not directly contain members such as fields or methods
namespace Proj
{
public partial class Form1 : Form
{
private string[] tx_data = new string[14];
private string[] rx_data = new string[10];
public int i;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label16_Click(object sender, EventArgs e)
{
}
private void label18_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void txtTxmID1_TextChanged(object sender, EventArgs e)
{
}
private void txtTxmID5_TextChanged(object sender, EventArgs e)
{
}
private void lblRx2_TextChanged(object sender, EventArgs e)
{
}
private void lblRx5_TextChanged(object sender, EventArgs e)
{
}
private void cmdRead_Click(object sender, EventArgs e)
{
//For i = 1 To 6
// lblRx(i).Caption = rx_data(i + 1)
//Next i
string OutString = null;
string Instring = null;
int y = 0;
open_port;
//If the port is opened...
if (Comm1.PortOpen)
{
//tx_data(0) = "R"
//tx_data(1) = "I"
//tx_data(2) = "D"
//For i = 0 To 2
// Comm1.Output = tx_data(i)
//Next i
OutString = "RID";
Comm1.Output = OutString;
}
}
public void writeID(string SysID, string SchID, string DeptID, string BlkID, string LevelID, string ClkID)
{
string OutString = null;
OutString = "";
tx_data[0] = "R";
tx_data[1] = "P";
tx_data[2] = "g";
tx_data[3] = cvtHexToDec(SysID);
tx_data[4] = cvtHexToDec(SchID);
tx_data[5] = cvtHexToDec(DeptID);
tx_data[6] = cvtHexToDec(BlkID);
tx_data[7] = cvtHexToDec(LevelID);
tx_data[8] = cvtHexToDec(ClkID);
System.DateTime mytime = DateTime.MinValue;
int HOU = 0;
int MIN = 0;
int SEC = 0;
mytime = Time; //obtain current system time
HOU = mytime.Hour; //obtain current system hour
MIN = mytime.Minute; //obtain current system minute
SEC = mytime.Second; //obtain current system seconds
tx_data[9] = cvtHexToDec(System.Convert.ToString(HOU));
tx_data[10] = cvtHexToDec(System.Convert.ToString(MIN));
tx_data[11] = cvtHexToDec(System.Convert.ToString(SEC));
tx_data[12] = cvtHexToDec("00");
for (i = 0; i <= 12; i++)
{
OutString = OutString + tx_data[i];
}
open_port;
//If the port is opened...
if (Comm1.PortOpen)
{
Comm1.Output = OutString;
Comm1.PortOpen = false;
}
}
public object cvtHexDec(string txtID)
{
string firstnum = null;
string secnum = null;
int f = 0;
int s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
firstnum = "0";
secnum = txtID.Substring(0, 1).ToUpper();
}
for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (firstnum == (char)(i))
{
f = (i - 55) * 16;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (firstnum == (char)(i))
{
f = (i - 48) * 16;
break;
}
}
for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (secnum == (char)(i))
{
s = i - 55;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (secnum == (char)(i))
{
s = i - 48;
break;
}
}
f = f + s; //add the total of fisrtnum & secnum dec
cvtHexDec = (char)(f); //convert back to char
}
public object cvtHexToDec(string txtID)
{
string firstnum = null;
string secnum = null;
byte f = 0;
byte s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
firstnum = "0";
secnum = txtID.Substring(0, 1).ToUpper();
}
if (System.Convert.ToInt32(firstnum[0]) >= 65)
{
f = System.Convert.ToInt32(firstnum[0]) - 55;
}
else
{
f = System.Convert.ToInt32(firstnum[0]) - 48;
}
f = f * 16;
if (System.Convert.ToInt32(secnum[0]) >= 65)
{
s = System.Convert.ToInt32(secnum[0]) - 55;
}
else
{
s = System.Convert.ToInt32(secnum[0]) - 48;
}
f = f + s; //add the total of fisrtnum & secnum dec
return (char)(f); //convert back to char
}
private void cmdWrite_Click(object sender, EventArgs e);
}
writeID(txtTxmID0.Text.ToUpper(),txtTxmID1.Text.ToUpper(),txtTxmID2.Text.ToUpper(), txtTxmID3.Text.ToUpper(), txtTxmID4.Text.ToUpper(),txtTxmID5.Text.ToUpper());
}
|
|
|
|
|
it's a quite large amount of code: please note that the compiler reports the line number where error occurs (and also the IDE helps you to locate the error).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Error1 is telling you that something is declared where it's not allowed to be. The first variables in your code
private string[] tx_data = new string[14];
private string[] rx_data = new string[10];
public int i;
need to be moved so that they're declared inside of your class Form1 . This also generates Error2 and Error3, so fix the first one and you fix them all.
On an unrelated note, the arrays tx_data and rx_data are being indexed using parentheses - tx_data(0) = "R" - which is incorrect. They need to be indexed with brackets instead: tx_data[0] = "R"
|
|
|
|
|
Hi,
Looking at the xml below, please let me know how to retrieve the data for the value elements.
Thanks
<fxspotrate code="EURUSD">
<values>
<value type="BID">1.3607
<value type="ASK">1.3608
<value type="MID">1.36075
|
|
|
|
|
Please repost and check the Ignore HTML tags in the message so that the < > show up.
Thanks,
Ben
|
|
|
|
|
<FXSpotRate code="EURUSD">
<values>
<value type="BID">1.3607</value>
<value type="ASK">1.3608</value>
<value type="MID">1.36075</value>
</values>
</FXSpotRate>
|
|
|
|
|
Something like this should work:
XmlDocument xDoc = new XmlDocument();
xDoc.InnerXml = @"<FXSpotRate code='EURUSD'><values><value type='BID'>1.3607</value><value type='ASK'>1.3608</value><value type='MID'>1.36075</value></values></FXSpotRate>";
XmlNodeList nodes = xDoc.SelectNodes("/FXSpotRate/values/value");
foreach (XmlNode xn in nodes)
{
//access the node info in here
}
Hope that helps.
Ben
|
|
|
|