|
This is the data in the list box, from a database
Johnie Black
Sarah Smith
Carol Willis
Maggie Dubois
This is the data in the combo Box
(M)
(F)
I want to select a name in the listbox then when I proceed to select the gender from the comboBox the value I select must be added to the end of the name that is selected
example.
Carol Willis(F)
Any form of help will be appreciated
|
|
|
|
|
On 'selectedIndexChanged' event of combo box, get selected text from it and append it to selected text of Listbox
Note: There is no direct way to append text, you need to first remove selected name from listbox and then add new name with gender
-hope it helps
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
|
A few comments:
1. consider the design of displaying the abbreviation for the gender at the end of the name. If you have a synchronized ComboBox/ListBox isn't it enough that your current choice in the ListBox exposes its gender value in ComboBox ?
2. Have you worked with DataBinding these Controls: that's the way to get them synchronized; in WinForms that does have a certain over-head: you may have to reset the binding state as the data type you bind to changes its internal values.
3. Consider using a Dictionary where the Keys are strings, and the Values are either strings or an Enum.
public enum GenderType
Indeterminate,
Ambivalent,
RefuseToState,
Male,
Female,
Hermaphrodite,
TransPreOpMToF,
TransPreOpFToM,
TransPostOpMToF,
TransPostOpFToM,
Eunuch,
Alien
}
private Array EnumTypeValues { set; get; }
private BindingSource EnumBindingSource { set; get; }
public void SomeMethod(Type enumtype, ComboBox combo)
{
EnumTypeValues = Enum.GetValues(enumtype);
EnumBindingSource = new BindingSource();
EnumBindingSource.DataSource = EnumTypeValues;
combo.DataSource = EnumBindingSource;
combo.DisplayMember = "Name";
combo.SelectedValueChanged += ComboOnSelectedValueChanged;
}
private void ComboOnSelectedValueChanged(object sender, EventArgs eventArgs)
{
GenderType gType = (GenderType) comboBox1.SelectedValue;
switch (gType)
{
case GenderType.Indeterminate:
break;
case GenderType.Male:
break;
case GenderType.Female:
break;
case GenderType.Ambivalent:
break;
case GenderType.Alien:
break;
default:
break;
}
}
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
BillWoodruff wrote: public enum GenderType
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I want to develop an app that gets employee-data from the SharePoint - My Site Collection and I'd like to change their properties through webservice communication.
What is the best practice to get me going?
I'm searching for a sample of:
1. The webservice communication
2. A get function to retrieve info
3. A set function to set properties
If anyone has the experience and can help me with this, that would be gold.
|
|
|
|
|
Member 12482866 wrote: What is the best practice to get me going? Hook up with MSDN[^]. Using that link you can ask what sites are in a collection, enumerate them, and get/set some properties.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I need a simple code...that will just get selected item data od my listView column selected item.
i have few items on listview colum
Hello| World | What | is
when i will click on HELLO column it will show "Hello" on messagebox.
Thanks
|
|
|
|
|
Sorry, but this website isn't a code to order service. The purpose of these forums is to help with problems you encounter while trying on your own.
Give it a go yourself and if you encounter a problem, post your code and we will try to help you.
You might also search the abundance of articles here to get some inspiration or maybe even find exactly what you're looking for.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I am really sorry.
=>Give it a go yourself and if you encounter a problem, post your code and we will try to help you.
You are right. i should post my code here first...Sorry for my current work.
Thank you for you advice... i am going to correction it
|
|
|
|
|
|
SYSTEM_INFO sys_info = new SYSTEM_INFO();
GetSystemInfo(out sys_info);
IntPtr proc_min_address = sys_info.minimumApplicationAddress;
IntPtr proc_max_address = sys_info.maximumApplicationAddress;
long proc_min_address_l = (long)proc_min_address;
long proc_max_address_l = (long)proc_max_address;
IntPtr processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_WM_READ, false, process.Id);
MEMORY_BASIC_INFORMATION mem_basic_info = new MEMORY_BASIC_INFORMATION();
int bytesRead = 0;
string arquivoName = string.Format(@"Dumps\Dump_{0}_{1:dd_MM_yyyy HH_mm_ss}.txt", process.ProcessName, DateTime.Now);
using (FileStream fs = File.Create(arquivoName))
{
using (StreamWriter sw = new StreamWriter(fs))
{
while (proc_min_address_l < proc_max_address_l)
{
VirtualQueryEx(processHandle, proc_min_address, out mem_basic_info, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION)));
if (mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT)
{
byte[] buffer = new byte[mem_basic_info.RegionSize];
ReadProcessMemory((int)processHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);
string info = string.Empty;
for (int i = 0; i < mem_basic_info.RegionSize; i++)
{
if ((char)buffer[i] != '\0')
{
string buf = string.Concat((char)buffer[i]);
string pattern = @"(\d|=|\s)";
Match match = new Regex(pattern).Match(buf);
if (match.Success)
info = string.Format("{0}{1}", info, buf);
}
}
sw.WriteLine(info);
}
proc_min_address_l += mem_basic_info.RegionSize;
proc_min_address = new IntPtr(proc_min_address_l);
}
sw.Close();
}
}
}
|
|
|
|
|
Don't cross post: you already have this in QA, so adding it here as well just duplicates work - and that annoys people. Pick one, and stick to it.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
how do I get the information from a site of a button?
|
|
|
|
|
What information from what button?
Your question is not clear
|
|
|
|
|
information is passed !! as login and password etc
|
|
|
|
|
As Chill60 says, this is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
We only get exactly what you tell us to work from - and you haven't told us what environment you want to work in (Website? WinForms? WPF? Console? Other?), where the "site" is, what "button" is involved, or even what kind of information you are trying to get from where!
Try and explain as if you were talking to your mother on the 'phone - that way you don't assume knowledge we don't have so much!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
information that the Website Button is passing
|
|
|
|
|
What website?
Do you really think that you are supplying enough information for anyone to help you?
|
|
|
|
|
Stop typing as little as possible and think about the question you want answered: at the moment you have done the equivalent of breaking down in the middle of nowhere and calling the garage and saying "It Broke". When they ask "what's the problem, what's the car, where are you?" all you do is say "It's a Ford" and put the phone down. How long do you think it will be before the garage arrives with the right bits to fix your car?
We're the same: there are potentially thousands of possible combinations of ways you could mean - and we have no idea which one you are trying to get to. So help us to help you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I will rephrase and I will speak!thx brow
|
|
|
|
|
I don't know which is better, or worse, having code that works for reasons you don't understand, or having code that breaks for reasons you don't understand
Today I was testing the use of a complex dictionary of the form:
public Dictionary<KeyValuePair<T1,T2>, List<T3>> I was surprised to find that I could iterate ... in a lambda expression passed as the argument to a Func ... over the List of T3 with a 'for loop and change the values without getting the "attempt to modify ..." error. Example:
Test = new Dictionary<KeyValuePair<string, int>, List<int>>
{
{new KeyValuePair<string,int>("hello",1),
new List<int> {1,2,3,4}},
{new KeyValuePair<string,int>("goodbye",2),
new List<int> {6,7,8,9}}
};
foreach (var kvp in Test)
{
for (int i = 0; i < kvp.Value.Count; i++)
{
kvp.Value[i] *= 10;
}
} Of course, you can never change the value of the Key or Value of the KeyValuePair ... they have no setters, but, I was surprised I could modify the value in this kind of loop ... I assume I could always modify the value outside of a loop where I iterated across the structure.
So, why don't this break ? My memory includes the use of various yogic contortions a few years ago to avoid the "can't modify collection" error.
Come to think on it: I distrust code that works for reasons I don't understand more than ... the other
thanks, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
It works because you aren't modifying anything the iterator needs to worry about: neither the key nor the value are being modified in any way (since they are a struct you can't change and a reference). You can modify the content of the object the reference "points" to very easily and legally inside the foreach, because you aren't trying to change the values in the collection you are iterating over.
List<MyClass> list = new List<MyClass>();
for (int i = 0; i < 5; i++)
{
MyClass mc = new MyClass() { s = i.ToString() };
list.Add(mc);
}
foreach (MyClass mc in list)
{
mc.s = mc.s + " changed!";
}
foreach (MyClass mc in list)
{
Console.WriteLine(mc.s);
}
Will give you:
0 changed!
1 changed!
2 changed!
3 changed!
4 changed! But obviously trying to change the actual value will give you a compilation error:
foreach (MyClass mc in list)
{
mc = new MyClass() { s = mc.s + " Changed again!" };
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks Grif ! I don't know my trying to grok this slips off me brain like noodles slip off a spoon. These memories I have of using exotic means to modify collections to avoid error ... I believe one of the memories is of a technique you posted years ago ... something about iterating from end of the collection to the start. Alas, memory, unreliable companion as age ticks off my telomeres
cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
Off topic, but on subject - did your op get cancelled again?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|