|
Thank you.
I tried code below but dropdown list shows only code.
How to force it to show both code and name ?
Andrus.
using System.Collections.Generic;
using System.Windows.Forms;
class testForm : Form
{
testForm()
{
ComboBox cm = new ComboBox()
{
ValueMember = "Code"
};
List<Product> prodList = new List<Product>();
prodList.Add(new Product() { Code = "001", Name = "Wine", Cb = cm });
prodList.Add(new Product() { Code = "002", Name = "Beer", Cb = cm });
cm.DataSource = prodList;
cm.DataBindings.Add("SelectedValue", prodList, "Code");
Controls.Add(cm);
}
class Product
{
public string Code { get; set; }
public string Name { get; set; }
public override string ToString()
{
return Code + " " + Name;
}
}
static void Main()
{
Application.Run(new testForm());
}
}
Andrus
|
|
|
|
|
try to add only the class object. do not set databindings. then in the selectedindexchanged event
cast the selecteditem to the class object.
Product product = (Product)myComboBox.Items[myComboBox.SelectedIndex];
|
|
|
|
|
Thank you. I tried the code below but TextBox in combo shows name also.
How to show only code ?
using System.Collections.Generic;
using System.Windows.Forms;
class testForm : Form
{
testForm()
{
MultiComboBox cm = new MultiComboBox() ;
List<Product> prodList = new List<Product>();
prodList.Add(new Product() { Code = "001", Name = "Wine" });
prodList.Add(new Product() { Code = "002", Name = "Beer" });
cm.DataSource = prodList;
Controls.Add(cm);
}
class MultiComboBox : ComboBox
{
protected override void OnSelectedIndexChanged(System.EventArgs e)
{
Product product = (Product)Items[SelectedIndex];
SelectedItem = product.Code;
base.OnSelectedIndexChanged(e);
}
}
class Product
{
public string Code { get; set; }
public string Name { get; set; }
public override string ToString()
{
return Code + " " + Name;
}
}
static void Main()
{
Application.Run(new testForm());
}
}
Andrus
|
|
|
|
|
When the code runs, the value of Cb.Dropped is always false. Stepping through.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
|
Munna Sarfraz Ahmad,
And the question was?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thank you for the Copy and Paste directly from the internet.
Dave
|
|
|
|
|
Just a crop-dusting across forums. And they call themselves 'software engineers '.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
What on earth made you think you needed to post that here?
|
|
|
|
|
MarkBrock wrote: What on earth made you think you needed to post that here?
The hot summer has struck and paralysed his brain from thinking coherantly.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi Vladimir Afanasyev,
I read your article .NET - Diving into System Programming.It is really intresting.You had mention some links in order to gain the Intial knowledge of System found all three of the articles to be very informative. I am working on a little project that requires listing all the drivers for a certain device (much like the device manager in windows does) but I have been unable to accomplish it. Can you point me to a resource that explains this or give a brief explanation of how you could do it ? You mentioned Some of msdn but it does not work
Using Device Installation Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/setupapi_071eca3a-0cc3-4962-b3de-65dcf056c761.xml.asp
SetupDiBuildDriverInfoList
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/di-rtns_dd9aa1be-1a67-4cc6-8a06-5db71eecd322.xml.asp
SetupDiEnumDriverInfo
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/di-rtns_8d84a225-9dac-4ab3-8c9a-5048284d82be.xml.asp
SetupDiGetDriverInfoDetail
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/di-rtns_5a2fb98d-54ee-4290-9969-f5e12d77cbcf.xml.asp
SP_DRVINFO_DATA
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/di-struct_738a1fa5-729a-4464-af75-05591d68eef7.xml.asp
SP_DRVINFO_DETAIL_DATA
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/install/hh/install/di-struct_74ef2af7-e982-4041-9c39-605ca316359c.xml.asp
Thanks,
|
|
|
|
|
If this is a reply to an article, you're better off replying in that article's forum - it's unlikely that the particular author will stumble upon this post.
|
|
|
|
|
Under Win32 and COM development<< Windows Driver Kit, you will get all this information.
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
How Cud I get a popup in Window Application in asp.net?
|
|
|
|
|
You want ASP.NET in your C# application or launch a C# application from an ASP.NET site in the user's browser?
|
|
|
|
|
Hello,
VS 2008
I have the following code in my timer control
<br />
private void tmrVibrate_Tick(object sender, EventArgs e)<br />
{<br />
vibrateAlert = new Led();<br />
vibrateAlert.SetLedStatus(1, Led.LedState.On);<br />
Debug.WriteLine("Vibrating");<br />
Thread.Sleep(1000);<br />
vibrateAlert.SetLedStatus(1, Led.LedState.Off);<br />
}<br />
I have 2 buttons start and stop. Start will enable the timer and stop will disable the timer.
The problem was that the PDA would continuely vibrate. So I put it in the timer event and set the interval for 2 seconds. Then in the timer event I sleep for 1 second. This will vibrate it for 1 second then switch it off and do this every 2 seconds.
The problem now is, that the UI will freeze during the pause of 1 second.
Is there a better way to do this?
Many thanks for any advice,
|
|
|
|
|
You will need to do it in a background thread.
|
|
|
|
|
Hello,
I solved the problem using the code below and setting the boolean flag in the timer tick event. However, as the timer is enabled in a thread that is not the UI thread, when I set the timer to enabled to true, the timer doesn't start. I was thinking of invoking the timer. However, the timer doesn't have that property.
private int OnIncomingCall(int _callID, string _caller)<br />
{<br />
callID = _callID;<br />
caller = _caller; <br />
<br />
if (this.btnAnswer.InvokeRequired)<br />
{<br />
this.btnAnswer.Invoke(new EventHandler(UpdateAnswerButton));<br />
}<br />
<br />
if (this.lblCallStatus.InvokeRequired)<br />
{<br />
this.lblCallStatus.Invoke(new EventHandler(DisplayCaller));<br />
}<br />
this.tmrVibrate.Enabled = true;
<br />
drvAnswerCall(_callID, 180);
<br />
return 1;<br />
}
static Boolean ledStatus = true;
private void tmrVibrate_Tick(object sender, EventArgs e)<br />
{<br />
if (ledStatus == true)<br />
{<br />
vibrateAlert.SetLedStatus(1, Led.LedState.On);<br />
ledStatus = false;<br />
}<br />
else<br />
{<br />
vibrateAlert.SetLedStatus(1, Led.LedState.Off);<br />
ledStatus = true;<br />
}<br />
}
Many thanks for any more suggestions,
|
|
|
|
|
I can go from an IP to a byte array like this...
byte[] IPBytes = IP.GetAddressBytes();
How do I go back without this horrific mess?
byte[] ip = {127, 0, 0, 1};
IPaddress addr;
string str_ip = ip[0].ToString() + "." + ip[1].ToString() + "." + ip[2].ToString()
+ "." + ip[3].ToString();
addr = IPAddress.Parse(str_ip);
|
|
|
|
|
Just call a constructor of IPAddress class which accepts byte array.
Simple, isn't is? The only thing you need to do is read documentation
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
There I go trying to over complicate things. I did look through the documentation but I was to busy looking for a way to convert to look at the IPAddress Constructor.
|
|
|
|
|
Create a new instance of System.Net.IPAddress class with System.Net.IPAddress.IPAddress(byte[]) constructor.
|
|
|
|
|
hy everyone!
I do have a problem:
I insert a picture in an application and try to fetch it again with my tool. the strange thing is although i insert 300x300 dpi pics when fetching they are 299x299 dpi.
after fetching they should be converted to a pdf, but it doesn't accept the 299x299 dpi, but it works fine with 300x300 dpi. (it throws an error it can't handle the format because it is unknown)
is there a chance to check this and to correct it to 300 dpi?
to change it to 300 dpi hardcoded isn't a good idea because there could be 600x600 dpi pics as well etc.
but i wonder, where this 1 dpi was lost and why!
anyone of you a clue?
thanks!
stephan.
|
|
|
|
|
You can check/set the DPI within a Graphics object, but I am not sure how you process the image.
|
|
|
|