|
Ok i have a DataTable that has 2 columns: ID & Name
I have populated a combo box from that data table like so
ComboBox1.DataSource = XmlIn.Tables["Names"];
ComboBox1.DisplayMember = "Name";
Now when a user selects a name from the combobox and then clicks a button i need away to return the coresponding ID to that name.
I have thought of using a DataView to scan for the name and return the relevent number but was sure there was a tidier way to return the ID value.
Can any one help?
Thank you.
|
|
|
|
|
set the ValueMember property of the control:
ComboBox1.ValueMember = "ID";
ComboBox1.DisplayMember = "Name";
ComboBox1.DataSource = XmlIn.Tables["Names"];
Then, you can get the selected Value by using the SelectedValue property:
ComboBox1.SelectedValue;
Jon G
www.Gizmocoder.com
|
|
|
|
|
just add another line to you code after setting the displaymember -
combobox1.ValueMember = XmlIn.Tables["ID"];
then to get the id you could do something like -
combobox1.SelectedValue.toString()
gavirj
|
|
|
|
|
Hi, sorry to bother with the easy stuff. Im brand new to C#, and loving it BTW.
Anyway. coming from scripting everything in KORN and Perl I need an example of the following in c#.
I would like to see simple c# code to
open a file,
build each line into an array by splitting on a char,
and print that line on a match on any element on an array.
In perl it would go:
@array = `cat file`;
foreach $line (@array) {
if ( $array[0] =~m/something/ ){
print "$line\n";
}
A simple C# example to this would get me off the google prompt, and back in happyville.
--
sween
|
|
|
|
|
Try this one:
FileStream fs = new FileStream(fileName);
StreamReader reader = new StreamReader(fs);
String line = String.Empty
while( (line = reader.ReadLine()) != null ){
if(line.indexOf("something") > 0){
Console.WriteLine( line );
}
Regexp epression = new Regex("~m/something/")
if(expression.IsMatch(line)){
Console.WrileLine(line);
}
}
reader.close();
|
|
|
|
|
Thank you.
FileStream fs = new FileStream(FileName, FileMode.Open);
seemed to work a little better... but all is getting less fuzzy.
Thanks again.
--
sween
|
|
|
|
|
I want to do a edit usercontrol that like VC++. It can auto check user input text's length. But don't like c#,For example, "全角", it's lenthe is 4, isn't 2. How to do it?
|
|
|
|
|
Multiply the string's length value by 2. However, this is NOT indicitave of the amount of memory used by the string (length prefix etc).
To get a C++ representation of what the unicode string, you will probably want to convert the string to an array of short and manipulate it like that. Use the System.Text.Encoding namespace to convert the string to and from a short array.
|
|
|
|
|
when i write my custom collection, and then when i use it and add any member to it, it display default object name in the list.
i want to when add a member to list, i name it member.
|
|
|
|
|
I need to create a taskbar for windows in .NET. It needs to re-size the
available desktop as does the standard windows taskbar.
Can this be done and if so how ?
|
|
|
|
|
Hi CPians,
I need to find out first visible column of a RichTextBox . Please render suggestions how to go for it.
Thanks in advance.
Regards,
Jay.
|
|
|
|
|
Columns? In a RichTextBox? Whatever do you mean?
Are you talking about the first visible Text character?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave,
Sorry for not being too descriptive, I want to get first visible text character index.
Regards,
Jay.
|
|
|
|
|
Off the top of my head, no methods for this exist.
Are you talking about the first visible character in the RTF stream? I mean, strip away all the RTF formatting and getting the position in the stream of the first character that would render visibly in the control?
Or are you talking about the first visible character when scrolling the control contents left and right?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I mean first visible character when scrolling the control contents left and right.
|
|
|
|
|
Unfortunately, no methods exist for what you want to do. I can't really come up with a way to do it either.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi guys,
In my office a job is assigned to me to admin our web site from a windows C# application. The task involves, uploading only those files into web FTP folder (relative folders) which are last modified. Instead of web utility if anybody can help me to upload files/folders from a windows root directory into Windows FTP directory (created in Internet Information Service), I will be greatful.
Parameters provided to me:-
1. Web site name (you can consider it as Windows FTP directory in IIS)
2. admin Username
3. Password
The scene...
I have to receive a folder name in window application like...
d:\websites\message\
suppose [message] is my root folder in windows directory.... which is same as the root folder [message] in a website [www.clientmessage.com]
Awaiting for help.
thanks
Sharad
SHARAD KAPIL
|
|
|
|
|
Hi,
I have a strange problem (also difficult to explain but here goes) - basically I have a program that scans a email account (which receives faxes as tiff images as attatchments) when the program finds a new email it gets the tif saves it to a mySql database and also saves each individual image to the database. But sometimes one of the seperate images is corrupt i.e. I can see it in the database (blob editor - image) but i cant work with it at all - I can save it using mySql front but if i try and open the image it says drawing failed. If I try and use it in my code -
byte[] MyData = (byte[])dataread["fileData"];
System.IO.MemoryStream mem = new System.IO.MemoryStream(MyData);
mem.Flush();
System.Drawing.Image i = System.Drawing.Image.FromStream(mem);
i.Save(mem,System.Drawing.Imaging.ImageFormat.Gif);
it will give a gdi exception(a generic exception has occured) when i try create a image from the memoryStream
another strange thing is that whenever I get an image like this the length of the byte array is always 74240.
Also when I view the image in the tiff I can see no problems with it.
Any ideas/help would be greatly appreciated. Thanks.
Gavirj
|
|
|
|
|
|
Have a look at this:
http://www.forum-3dcenter.org/vbulletin/attachment.php?attachmentid=18784&stc=1
The text of the GroupBox that is in the other GroupBox is screwed up.
Definitely a bug that only occurs if you install .NET 1.1 ServicePack1!
Is there a possibility to report bugs to Microsoft?
Best Regards
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I've found this problem too.
I've contacted Microsoft about it because I could not find anywhere on any Microsoft website where I could report the bug, so I emailed them and they got back to me today.
Apparently, to report a bug I have to write a letter, yes a letter, not an email or an online form (as you would expect from a company that deals in modern technology) but a snail mail letter.
If you want to do so you will need to do the following, write a letter addressed to:
Attn: <Product Name> Development Group
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052
And in the letter tell them what you've got installed and your OS and all the other jib that they'll need to consistently reproduce the problem.
I'm going to try writing to them but I don't know how long it'll take me to do so (I'm lazy, you see).
|
|
|
|
|
-hi there guyz, does anyone knows about PC/SC using C# 'cause im having hard
time in coding it specially in SCard Get ATR and SCard Transmit.. any idea?! tnx for helping me..
|
|
|
|
|
I'd like to write a metronome application in C#.
What Timer class would you recommend for accurate time-keeping.
I also plan on using DirectSound to play the WAV files representing the ticks. Does this impose a significant overhead?
If you know of code for a metronome app in C#, I'd appreciate it. This would only be for personal reference. I will not copy the code and use it in my app.
|
|
|
|
|
NietzscheDisciple wrote:
What Timer class would you recommend for accurate time-keeping.
Just the normal one will be fine.
NietzscheDisciple wrote:
I also plan on using DirectSound to play the WAV files representing the ticks. Does this impose a significant overhead?
What on earth for ? Why rely on Direct Sound to play a simple sound file - it's overkill. And DirectSound is used in games that are doing a lot more than firing a timer, I doubt it will bring your app to it's knees if you use it
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks for the reply, Christian.
I've done some DirectSound programming and it's pretty neat. My apprehension was that the SecondaryBuffer wouldn't clear "cleanly enough" for this application. Esp. if the metronome was going at 180 bpm+.
|
|
|
|