|
Hello
I have a datagridview binded to a datatable : Wine
This datatable contains
CepageID
Cepage
percent
DGV shows Cepage and percent
I have another datatable Cepages
When the user wants to edit a cepage in the DGV I want to switch the textboxcell to a comboboxcell showing the different available cepages
Is it possible with a binded datagridview ?
Thanks for any help
|
|
|
|
|
Why not use DataGridViewComboboxColumn right away?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Thanks for your answer !
I do not use Combobox column because I want to keep the normal textbox display when the cell is not editing !
Combobox display takes to much space in the grid to display the item properly !
|
|
|
|
|
Set these properties for your DataGridView as below:
comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
woaw that sounds great
and so simple
thank you I'll try it
|
|
|
|
|
Hello d@nish
Your suggestion was fine !
I've done it that way
cbxCepage.DataSource = sCodes.dtCepages;
cbxCepage.DisplayMember = "Value";
cbxCepage.ValueMember = "ID";
cbxCepage.DataPropertyName = "ID";
dgvCepages.DataSource = null;
dgvCepages.AutoGenerateColumns = false;
dgvCepages.DataSource = Reg.Prod.dtCepages;
dgvCepages.EditMode = DataGridViewEditMode.EditOnEnter;
cbxCepage.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
|
|
|
|
|
Hi,
i'm confused. If String is a reference type, why b does not change if a is modified, since b is just referring to a?
E.g.
String a = "Hello";
String b = a;
a = a.ToUpper();
Console.WriteLine(a);
Console.WriteLine(b);
> HELLO
> hello
Thanks
|
|
|
|
|
uus831 wrote: If String is a reference type, why b does not change if a is modified, since b is just referring to a?
You're not passing a reference to a string, but invoking a method on such a reference, and putting the result back in a . The documentation[^] says that this method returns a copy of the string;
' Returns a copy of this String converted to uppercase. The method ToUpper is executed, and it returns a reference to a new string. This pointer is then stored in your A-variable, not touching B.
I are Troll
|
|
|
|
|
Yes, Microsoft purposely made the String type act like a value type, even though it is really a reference type; it is immutable. Any operations on a String produce a copy, or a partial copy, of the String; the underlying string data cannot be directly changed. This is why you have to do a = a.ToUpper(); in the first place, rather than the ToUpper() method directly changing the String . This is also the reason that the StringBuilder class exists, because it allows string manipulation without the extra copying, and thus has better performance in situations where lots of string manipulation will be happening.
|
|
|
|
|
Because it's not a.ToUpper() but a = a.ToUpper() - ToUpper doesn't change anything, it returns a new string.
If you change the actual string (yes you can, unsafe code), b should probably change
|
|
|
|
|
Ok, i understand. Thanks.
|
|
|
|
|
Hi,
I was wondering:
I have an user-control called myUserControl. This control contains items, say myUserControlItems. Now I want to add a property to myUserControl, which contains a list of myUserControlItems.
So:
myUserControl usrctrl = new myUserControl();
myUserControlItem usritem = new myUserControlItem();
myUserControl.Items.Add(usritem);
I can accomplish this by setting the type of the property to myUserControlItem[], but this isn't as dynamic as e.g Listviewitems in a ListView.
Can somebody help me out on this one?
Greets,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
A property of type List<myUserControlItem> may suite your needs.
There's nothing left in my right brain and nothing right in my left brain. |
|
|
|
|
|
use a list instead of an array:
List<myUserControlItem> abc = new List<myUserControlItem>();
myUserControlItem usritem = new myUserControlItem();
abc.Add(usritem);
|
|
|
|
|
Zaegra wrote: Custom item list
you call it a list, yet you don't use a List<>?
|
|
|
|
|
Motivation is the key to software development.
|
|
|
|
|
I draw circle and line to windows form using with GDI.
Sample code;
Graphics graph = this.CreateGraphics();
graph.DrawArc(Pen.Red, new Rectangle(pFisrtPoint, new Size(pSecondPoint.X - pFirstPoint.X, pSecondPoint.Y - pFirstPoint.Y)), 0, 360);
Graphics graph = this.CreateGraphics();
graph.DrawLine(Pen.Red, pFirstPoint, pSecondPoint);
How can I delete shape when just mouse hover this shape painted area area?
Best Regards...
|
|
|
|
|
Hi,
This[^] explains how you should go about it.
|
|
|
|
|
This article is not related about my problem. Do you have any idea? Thanks...
|
|
|
|
|
yes it is, each time your drawing has to change, change the data and call Invalidate().
|
|
|
|
|
how can i use unsafe code?
|
|
|
|
|
You can create a unsafe code block using unsafe keyword and place all of your unsafe code inside it.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
i have code that use unsafe code but when i debug it an error "unsafe code may only appear if compiling with /unsafe"
what can i do?
|
|
|
|
|
Go to project properties. There, under Build tab, check allow unsafe code checkbox.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
thanks alot
|
|
|
|