|
The following code will get the value. You can ignore the fact that it is a DataGridViewComboBoxColumn for your purpose.
DataGridViewRow currRow = this.dataGridView1.CurrentRow;
this.txtValue.Text = currRow.Cells["CBColumn"].Value.ToString();
DataGridViewRow anyRow = this.dataGridView1.Rows[2];
this.txtValue.Text = anyRow.Cells["CBColumn"].Value.ToString();
DataGridViewCell currCell = this.dataGridView1.CurrentCell;
this.txtValue.Text = currCell.Value.ToString();
I have split the processing into two lines, and I would probably do this anyway because it is easier to understand. However, you could do it in one line, like this: (I have only shown the first one although you could do the same for all three)
this.txtValue.Text = this.dataGridView1.CurrentRow.Cells["CBColumn"].Value.ToString();
**NOTE**
'CBColumn' is the Name I have given to my DataGridViewComboBoxColumn , the Name property, not the HeaderText
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi group,
I'm converting a large old C++ program to C#. It has lots and lots and lots of istream/ostream io. Is there an equivalent io capability in C#? Any suggestions on the most efficient way to do this.
Thanks /Mike
|
|
|
|
|
The demo edition of our 'C++ to C# Converter' will allow conversion of some of the C++ IO methods/operators. Console.Write and Console.Read are used in addition to some helper methods for conversion of 'cin'.
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
There are tons of stream classes in C#. You should perhaps buy a C# reference.
If your C++ program includes extensions to iostreams, you're probably looking at a full rewrite of how you approach things.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for the answers. Here is a code fragment I found here <http: www.java2s.com="" tutorial="" cpp="" 0240__file-stream="" performbothinputandoutput.htm="">
Is there c# support for this type of stream io?
<br />
#include <iostream><br />
#include <strstream><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
char iostr[80];<br />
<br />
strstream strio(iostr, sizeof(iostr), ios::in | ios::out);<br />
<br />
int a, b;<br />
char str[80];<br />
<br />
strio << "10 20 testing ";<br />
strio >> a >> b >> str;<br />
cout << a << " " << b << " " << str << endl;<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
In C# i placed an rdlc report viewer on a windows form now when i make an object of the form it wont call the report viewer. please help if any .
<pre>
RdlcReportViewer rv = new RdlcReportViewer();
rv.<u>reportViewer1</u>.LocalReport.EnableHyperlinks = true;
rv.<u>reportViewer1</u>.LocalReport.ReportEmbeddedResource= "test.RdlcRptPayments.rdlc";
</pre>
thankx.
|
|
|
|
|
Have you looked at this? msdn[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
I have come across an interesting problem. If I have a DataSet which I've read from an XML file. Then I call WriteXML to my memory stream. If I try read it back into a dataset I get the following error "Root Element is missing"
here is some example code.
DataSet ds = new DataSet(); <br />
ds.ReadXmlSchema(@"C:\Foo\FooSchema.xsd");<br />
ds.ReadXML(@"C:\Foo\Foo.xml"); <br />
<br />
MemoryStream ms = new MemoryStream(); <br />
ds.WriteXml(ms); <br />
ds.ReadXml(ms);
Does anyone know why? or how I can use a DataSet to read directly from a MemoryStream?
modified on Tuesday, October 20, 2009 9:58 AM
|
|
|
|
|
The current position pointer of the memory stream is left at the end when you do the ds.WriteXml . You have to do something (apologies, no access to IDE right now) like ms.CurrentPosition = 0; before the the ReadXml to move it back to the start.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
In your example you try to read after the written data (MemoryStream position != 0).
You have to reset the read position of the memory stream.
MemoryStream ms = new MemoryStream();
ds.WriteXml(ms);
ms.Seek(0, SeekOrigin.Begin);
ds.ReadXml(ms);
|
|
|
|
|
Aah yes, silly me, I forgot about the pointer.
Thank you!
|
|
|
|
|
Keefb is coirrect, you have to rewind the stream, using:
if (ms.CanSeek)
{
ms.Seeek(0,SeekOrigin.Begin);
}
But be aware it may not work! You may well need ms.FlushFinalBlock() to ensure that last bit of data is written.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
If you look at the value of ms.Position after you have wrote in it, you'll see that has the same value of ms.Length . That is because you have just written into the stream and the stream cursor is located at the end.
Due to that, if you try to read the stream content, the reader doesn't found anything to read, giving the "Root Element is missing" exception.
Call ms.Seek(0, SeekOrigin.Begin) (or set ms.Position = 0 ) to move the cursor back to the beginning of the stream after writing and before reading.
|
|
|
|
|
if all else fails, maybe try and set ms.Position=0;
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
This is regarding late binding on a custom DLL in C#.
Basically, I have a self-written DLL which I wrapped using TLBIMP.exe.
Now I am trying to map the DLL's events to that of my own form. The events inside the DLL originate from a class.
I have tried almost every solution I was able to Google and nothing works.
Please do not reply to my thread if you have just Googled for a solution yourself, I need to hear from someone who has done this before. I've tried Google.
Details:
O.k, I'm going to use simpler names than that of my actual code.
My DLL file is called wrapper_MyDLL.dll and I load it as follows:
System.Reflection.Assembly _assembly = Assembly.LoadFile("wrapper_MyDLL.dll");
I save the Type as follows:
System.Type _classType = _assembly.GetType("wrapper_MyDLL.MyModuleClass");
I save the Class Object as follows:
object _classObject = Activator.CreateInstance(_classType);
Now from this point on I have tried so many different pieces of code to get the event that I'd rather not try to provide my attempted solution.
However, I can give some detail about my DLL.
If I loop through _assembly.getTypes() I get (among other) the following two classes:
* wrapper_MyDLL.MyModuleClass<br />
* wrapper_MyDLL.__MyModule_ReceivedMessageEventHandler
Inside the class wrapper_MyDLL.MyModuleClass, the DLL exposes the following (among other):
Methods:
* add_ReceivedMessage<br />
* remove_ReceivedMessage
Event(s):
* ReceivedMessage
Inside the class wrapper_MyDLL.__MyModule_ReceivedMessageEventHandler, the DLL exposes the following (among other):
Methods:
* get_Method<br />
* get_Target
Properties:
* Method<br />
* Target<br />
Now, how do I go about having that event (ReceivedMessage) fire in a method in my C# project?
If you think you can help and need any more info, let me know.
Kind Regards
modified on Tuesday, October 20, 2009 9:14 AM
|
|
|
|
|
I got absolutely no idea on how you'd hook up that event, and you don't want me to Google. If it were an interview-question, I'd suggest sending a message to the mainform and handle it in the WndProc. Kinda like InterOpping to yourself
I are Troll
|
|
|
|
|
See, that's why I asked you not to reply if you don't actually know what my problem is.
You marked your response as an ANSWER while in fact I still have no answer at all.
What am I supposed to do now? Repost my post as a new to regain my post's "unanswered" status?
Sorry for coming across as hostile, I appreciate the suggestion you made.
The thing is, here are many posters who, for some reason, try to answer just about every problem whether they know the answer or not, simply to up their number of posts. And once a post has been answered it has much less of a chance of being seen by someone who could actually help.
Understand my reasoning?
|
|
|
|
|
Hi!
I will use the DateTimePicker with working BackColor in a project of me, but in the project I need to see witch part of the customformated DateTimePicker is selected. A normal DateTimePicker from MS has this funktion but on that i can't change the BackColor.
Thanks,
blind1985
|
|
|
|
|
i have tow datagridview i wanna delete from the first grid and add the deleted row to other grid ...
thx all
|
|
|
|
|
And what kind of problems with performing this are you having?
|
|
|
|
|
i dont have problem
but i wanna take the professional solution
using datagrid classes
thx for reply
|
|
|
|
|
what's the problem ?
DataGridViewRow firstRow = grid1.Rows[0];
grid1.Rows.Remove(firstRow);
grid2.Rows.Add(firstRow);
that's all...
|
|
|
|
|
|
can i do that by doubleclik on row???
|
|
|
|
|
Ya you can!!
just write this code in the datagridviewcelldoubleclick event.
your job is done dude!!
|
|
|
|