By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

DataGrid Complex Binding

P: n/a
K
I created a collection which is derived from ArrayList and implements
IBindingList and ITypedList.

Then I bound the DataSource of a data grid into the collection. It could
show up the data but the column heading is not in the right order, for eg. I
want "ID" column to be the first column but it showed as the second column.

Another problem is that anyway i can leave a blank row in the grid to add a
new row automatically if the user selected and tyepd something there ?

Thanks
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hello,

To define which columns are visible and in what order, you will need to
create a custom System.Windows.Forms.DataGridTableStyle with a set of
System.Windows.Forms.DataGridColumnStyle-s.

The availability of the blank row at the bottom is controlled by the
AllowNew property of the IBindingList interface. As far as I remember,
returning "true" will result in this row being displayed.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I created a collection which is derived from ArrayList and implements
IBindingList and ITypedList.

Then I bound the DataSource of a data grid into the collection. It could
show up the data but the column heading is not in the right order, for eg. I want "ID" column to be the first column but it showed as the second column.
Another problem is that anyway i can leave a blank row in the grid to add a new row automatically if the user selected and tyepd something there ?

Thanks


Nov 15 '05 #2

P: n/a
K
Thanks so much for your quick resonse. I'll try DataGridColumnStyle, but for
AllowNew matter, my collection class is returning true for
IBindingList.AllowNew, and the blank row doesn't show up too.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ul**************@TK2MSFTNGP10.phx.gbl...
Hello,

To define which columns are visible and in what order, you will need to
create a custom System.Windows.Forms.DataGridTableStyle with a set of
System.Windows.Forms.DataGridColumnStyle-s.

The availability of the blank row at the bottom is controlled by the
AllowNew property of the IBindingList interface. As far as I remember,
returning "true" will result in this row being displayed.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I created a collection which is derived from ArrayList and implements
IBindingList and ITypedList.

Then I bound the DataSource of a data grid into the collection. It could
show up the data but the column heading is not in the right order, for
eg. I
want "ID" column to be the first column but it showed as the second column.

Another problem is that anyway i can leave a blank row in the grid to

add a
new row automatically if the user selected and tyepd something there ?

Thanks

Nov 15 '05 #3

P: n/a
You're welcome. You can also ensure this (quoted from the MSDN Library):

-------------------
Remarks
If IList.IsFixedSize or IList.IsReadOnly is true, this property returns
false.
-------------------

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
Thanks so much for your quick resonse. I'll try DataGridColumnStyle, but for AllowNew matter, my collection class is returning true for
IBindingList.AllowNew, and the blank row doesn't show up too.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ul**************@TK2MSFTNGP10.phx.gbl...
Hello,

To define which columns are visible and in what order, you will need to
create a custom System.Windows.Forms.DataGridTableStyle with a set of
System.Windows.Forms.DataGridColumnStyle-s.

The availability of the blank row at the bottom is controlled by the
AllowNew property of the IBindingList interface. As far as I remember,
returning "true" will result in this row being displayed.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I created a collection which is derived from ArrayList and implements
IBindingList and ITypedList.

Then I bound the DataSource of a data grid into the collection. It could show up the data but the column heading is not in the right order, for

eg.
I
want "ID" column to be the first column but it showed as the second

column.

Another problem is that anyway i can leave a blank row in the grid to

add
a
new row automatically if the user selected and tyepd something there ?

Thanks



Nov 15 '05 #4

P: n/a
K

My collection is derived from ArraryList, and I checked from MSDN, the
default for IList.IsReadOnly and IList.IsFixedSize are both "false". In my
collection, the IBindingList.AllowEdit, IBindingList.AllowRemvoe and
IBindingList.AllowNew are both true. But, DataGrid still didn't show up the
blank row for me to create a new row.

For the row column ordering, I tried to add TabeStyles in design time called
"headerStyle" and in it, i added two DataGridColumnStyles,
1. Header Text -> "Choices" , Mapping Name -> "ID"
2. Header Text -> "Wording", Mapping Name -> "Wording"

where ID and Wording are the actual properties in my contained objects.

Is it because I bind the datasource at run time to my collection, so the
headers didn't show up correctly ??

I got one more confused. What should i put in Mapping Name for my Table
Style "headerStyle" ? ( I just leave it blank now )

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
You're welcome. You can also ensure this (quoted from the MSDN Library):

-------------------
Remarks
If IList.IsFixedSize or IList.IsReadOnly is true, this property returns
false.
-------------------

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
Thanks so much for your quick resonse. I'll try DataGridColumnStyle, but

for
AllowNew matter, my collection class is returning true for
IBindingList.AllowNew, and the blank row doesn't show up too.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ul**************@TK2MSFTNGP10.phx.gbl...
Hello,

To define which columns are visible and in what order, you will need to create a custom System.Windows.Forms.DataGridTableStyle with a set of
System.Windows.Forms.DataGridColumnStyle-s.

The availability of the blank row at the bottom is controlled by the
AllowNew property of the IBindingList interface. As far as I remember,
returning "true" will result in this row being displayed.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> I created a collection which is derived from ArrayList and implements > IBindingList and ITypedList.
>
> Then I bound the DataSource of a data grid into the collection. It could > show up the data but the column heading is not in the right order, for eg.
I
> want "ID" column to be the first column but it showed as the second
column.
>
> Another problem is that anyway i can leave a blank row in the grid
to add
a
> new row automatically if the user selected and tyepd something there

? >
> Thanks
>
>


Nov 15 '05 #5

P: n/a
> My collection is derived from ArraryList, and I checked from MSDN, the
default for IList.IsReadOnly and IList.IsFixedSize are both "false". In my
collection, the IBindingList.AllowEdit, IBindingList.AllowRemvoe and
IBindingList.AllowNew are both true. But, DataGrid still didn't show up the blank row for me to create a new row.
To be honest, I have no idea. It is of course virtually possible that
DataGrid has a hard-coded type check, and if the type is not DataTable or
DataView, the "new" row never appears, but how one can find it out?
Is it because I bind the datasource at run time to my collection, so the
headers didn't show up correctly ??
You should create DataGridTableStyle/DataGridColumnStyle before binding the
data source. You should also use the SetDataBinding method.
I got one more confused. What should i put in Mapping Name for my Table
Style "headerStyle" ? ( I just leave it blank now )
I think its value should be equal to the grid's DataMember property value.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:e5**************@TK2MSFTNGP10.phx.gbl...
My collection is derived from ArraryList, and I checked from MSDN, the
default for IList.IsReadOnly and IList.IsFixedSize are both "false". In my
collection, the IBindingList.AllowEdit, IBindingList.AllowRemvoe and
IBindingList.AllowNew are both true. But, DataGrid still didn't show up the blank row for me to create a new row.

For the row column ordering, I tried to add TabeStyles in design time called "headerStyle" and in it, i added two DataGridColumnStyles,
1. Header Text -> "Choices" , Mapping Name -> "ID"
2. Header Text -> "Wording", Mapping Name -> "Wording"

where ID and Wording are the actual properties in my contained objects.

Is it because I bind the datasource at run time to my collection, so the
headers didn't show up correctly ??

I got one more confused. What should i put in Mapping Name for my Table
Style "headerStyle" ? ( I just leave it blank now )

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
You're welcome. You can also ensure this (quoted from the MSDN Library):

-------------------
Remarks
If IList.IsFixedSize or IList.IsReadOnly is true, this property returns
false.
-------------------

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"K" <k@taka.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
Thanks so much for your quick resonse. I'll try DataGridColumnStyle, but
for
AllowNew matter, my collection class is returning true for
IBindingList.AllowNew, and the blank row doesn't show up too.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:ul**************@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> To define which columns are visible and in what order, you will need to > create a custom System.Windows.Forms.DataGridTableStyle with a set
of > System.Windows.Forms.DataGridColumnStyle-s.
>
> The availability of the blank row at the bottom is controlled by the
> AllowNew property of the IBindingList interface. As far as I remember, > returning "true" will result in this row being displayed.
>
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
> http://x-unity.miik.com.ua/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE
>
> "K" <k@taka.com> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
> > I created a collection which is derived from ArrayList and
implements > > IBindingList and ITypedList.
> >
> > Then I bound the DataSource of a data grid into the collection. It

could
> > show up the data but the column heading is not in the right order, for eg.
> I
> > want "ID" column to be the first column but it showed as the second > column.
> >
> > Another problem is that anyway i can leave a blank row in the grid to add
> a
> > new row automatically if the user selected and tyepd something
there ? > >
> > Thanks
> >
> >
>



Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.