|
Hi
You shall insert a column to your datagridview with type of button(for example).
you can set caption of button as "Select".
So use the CellContentClick event and in the body of this event for getting data of row that user clicked on the button of same row use below code :
dataGridView1.Rows[e.RowIndex].Cells[i].Value.ToString();
Best Regards,
Reza Shojaee
|
|
|
|
|
any one knows how to pass an object by value instead of reference in C#?
|
|
|
|
|
Step 1) Ensure it's a value.
Step 2) Pass it.
|
|
|
|
|
Hi,
that is not possible.
Not sure why you think you want that. Maybe what you need is a clone, i.e. a second object that is an exact copy of the original, so changing it would not change the original. I very seldom need that though. I suggest you explain the situation.
|
|
|
|
|
thanx, i just wanted to know whether it is possible or not , cloning means before sending we create a copy of the object and send it to the method. hmmm.. thanx.
|
|
|
|
|
|
prasadbuddhika wrote: cloning means before sending we create a copy of the object and send it to the method.
Which is also passed by reference...
|
|
|
|
|
|
But most of those values are references.
|
|
|
|
|
Everything that is passed is a value in the truest sense. However that value is (most) often a reference to the object rather than the 'value' itself.
The only way to do what the op wants is to create a new object (therefore a new reference) and copy the values the object holds. Where the object's values are also references, new copies of those also need to be created. This needs to be done recursively until all object references have been recreated.
This is known as deep cloning and, as you can see, can be quite an involved and complex task which is why there is no built in Clone method in the framework. The closest we have is ICloneable which has (of course as it's an interface) to be implemented by the creator of the class.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Assume I write a class called Customer. On it are CustomerKey and CustomerName properties. You set the key to the customer's PK and call the SaveChanges method.
The SaveChanges method first calls a private bool method called Validate. If the CustomerName property is not completed, how would you deal with it? Throw an exception? Maybe set an ErrorMessage property?
Bear in mind that this class may never actually be bound to any UI. It may only ever be called from another non-visual class.
Everything makes sense in someone's mind
|
|
|
|
|
What we do is use an Errors collection, and add the fields that failed validation to the collection. The Validate method then returns false. The calling class looks something like
if (customer.Validate())
{
}
else
{
foreach (Error fieldError in customer.Errors)
{
}
}
Don't blame me. I voted for Chuck Norris.
|
|
|
|
|
That's an excellent idea. Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
Throwing exception would be fair enough.
Best wishes,
Navaneeth
|
|
|
|
|
i want to filter something like string type in my textbox but my code is not working..how do i fix this
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
bindingSource1.Filter = "LASTNAME = LIKE% + textBox1.Text";<br />
bindingSource1.Sort = "LASTNAME ASC";<br />
}<br />
<br />
<br />
|
|
|
|
|
According to the example on MSDN[^], you'd need to re-assign the bindinsource to the datagridview;
BindingSource1.Filter = "LASTNAME='Owner'";
BindingSource1.Sort = "LASTNAME ASC";
dataGridView1.DataSource = BindingSource1;
I are Troll
|
|
|
|
|
crisjala wrote: bindingSource1.Filter = "LASTNAME = LIKE% + textBox1.Text";
You might also want to pick up a book on beginners C# and work through it. It seems you have no idea how strings work.
This line should be closer to
bindingSource1.Filter = @"LASTNAME LIKE% " + textBox1.Text;
though using user input directly without validating it could be considered one of the great sins of programming.
|
|
|
|
|
I'm trying to find a cleaner way to reflectively get at the contents of my class that are lists of other classes:
class BigClass
{
public List<LittleClass1> LittleList1;
public List<LittleClass2> LittleList2;
public string BigString;
}
class LittleClass1
{
public string a;
public int b;
}
class LittleClass2 : LittleClass1
{
public string c;
}
To look into BigClass I use
foreach (FieldInfo fi in BigClass.GetFields())
{
if (fi.GetValue(bigClassInstance).ToString().StartsWith("System.Collections.Generic.List"))
{
}
}
It finds the lists, and I can process them from there, but there must be a better way.
|
|
|
|
|
Try the is and as operators rather than string comparisons.
And probably look for IEnumerable rather than List .
|
|
|
|
|
Thank you. I'll put up a big sign on my desk with "is " and "as " and ToString() so I don't have to ask this again.
|
|
|
|
|
|
is it possible to update twitter status from my C# application using textbox?
|
|
|
|
|
Absolutely, since Twitter has an interface built in to everything. In fact, if you write text on a paper tablet it will update your Twitter account also, magically, with no coding at all.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'm pretty sure it's even built into tiolet paper judging by some of the posts.
Don't blame me. I voted for Chuck Norris.
|
|
|
|
|
Try googling before asking next time. For a question like this, I'd suggest the terms 'Twitter API'. This is the first result.
http://apiwiki.twitter.com/[^]
|
|
|
|