473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

DataGrid Complex Binding

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
5 2512
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
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
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
4
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
0
by: Dave | last post by:
The question I have is how to -=> Effectively <=- and -=> Efficently <=- bind a DataGrid to a 1 deep organizational chart, where "R" would be a row of data and 1..N would be the columns of the row....
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
2
by: MichaelY | last post by:
Ok...I'm gonna regret this...but here goes....(promise I'm not trolling) After several years of using the provided ASP.NET data display controls (DataGrids, Repeaters, and now the GridView amoung...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.