|
Hello,
I've got a Form which has a dataGrid on it. In one of the columns of the
dataGrid, I've implemented a ComboBox using a DataGridComboBoxColumn Class.
I've also over ridden the other columns with a custom DataGridTextBoxColumn
class so I can color certain columns.
What I'm trying to do is.based on the selection in the ComboBox, I want to
color certain cells.
The problem I'm having is.when I make a selection in the ComboBox, the
_SelectedIndexchanged event for the DataGridComboBoxColumn class fires like
it should. At this point, when it fires, I'm in the DataGridComboBoxColumn
class, not in the main Form class. The only way I know of to reference the
main form is to instantiate a new class like.
MyForm myform = new MyForm();
But when I do this, I loose the state (session) data.
When this _SelectedIndexchanged (ComboBox) fires, I need a way to get back
into the main Form code so I can change the colors of certain columns.
I think there is a way to do this, I just don't know how.
Thanks for any help... | |
Share:
|
Randy,
The DataGridComboBoxColumn shouldn't be able to hook to the main form
like that. Rather, why not attach the form to the events on the data source
itself (the dataset) and detect when that column changes? When that
happens, you can set the color appropriately on the grid.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl... Hello,
I've got a Form which has a dataGrid on it. In one of the columns of the dataGrid, I've implemented a ComboBox using a DataGridComboBoxColumn Class. I've also over ridden the other columns with a custom DataGridTextBoxColumn class so I can color certain columns.
What I'm trying to do is.based on the selection in the ComboBox, I want to color certain cells.
The problem I'm having is.when I make a selection in the ComboBox, the _SelectedIndexchanged event for the DataGridComboBoxColumn class fires like it should. At this point, when it fires, I'm in the DataGridComboBoxColumn class, not in the main Form class. The only way I know of to reference the main form is to instantiate a new class like.
MyForm myform = new MyForm();
But when I do this, I loose the state (session) data.
When this _SelectedIndexchanged (ComboBox) fires, I need a way to get back into the main Form code so I can change the colors of certain columns.
I think there is a way to do this, I just don't know how. Thanks for any help...
| | |
That sounds good...but I'm not sure how to do it. You got any examples?
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl... Randy,
The DataGridComboBoxColumn shouldn't be able to hook to the main form like that. Rather, why not attach the form to the events on the data source itself (the dataset) and detect when that column changes? When that happens, you can set the color appropriately on the grid.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message news:OU**************@TK2MSFTNGP10.phx.gbl... Hello,
I've got a Form which has a dataGrid on it. In one of the columns of the dataGrid, I've implemented a ComboBox using a DataGridComboBoxColumn Class. I've also over ridden the other columns with a custom DataGridTextBoxColumn class so I can color certain columns.
What I'm trying to do is.based on the selection in the ComboBox, I want to color certain cells.
The problem I'm having is.when I make a selection in the ComboBox, the _SelectedIndexchanged event for the DataGridComboBoxColumn class fires like it should. At this point, when it fires, I'm in the DataGridComboBoxColumn class, not in the main Form class. The only way I know of to reference the main form is to instantiate a new class like.
MyForm myform = new MyForm();
But when I do this, I loose the state (session) data.
When this _SelectedIndexchanged (ComboBox) fires, I need a way to get back into the main Form code so I can change the colors of certain columns.
I think there is a way to do this, I just don't know how. Thanks for any help...
| | |
Randy,
Well, you have the data set available to you that you bind to the grid,
right? Just find the table in the collection exposed by the Tables property
on the data set, then attach to the ColumnChanged or ColumnChanging event.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... That sounds good...but I'm not sure how to do it. You got any examples?
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Randy,
The DataGridComboBoxColumn shouldn't be able to hook to the main form like that. Rather, why not attach the form to the events on the data source itself (the dataset) and detect when that column changes? When that happens, you can set the color appropriately on the grid.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message news:OU**************@TK2MSFTNGP10.phx.gbl... Hello,
I've got a Form which has a dataGrid on it. In one of the columns of the dataGrid, I've implemented a ComboBox using a DataGridComboBoxColumn Class. I've also over ridden the other columns with a custom DataGridTextBoxColumn class so I can color certain columns.
What I'm trying to do is.based on the selection in the ComboBox, I want to color certain cells.
The problem I'm having is.when I make a selection in the ComboBox, the _SelectedIndexchanged event for the DataGridComboBoxColumn class fires like it should. At this point, when it fires, I'm in the DataGridComboBoxColumn class, not in the main Form class. The only way I know of to reference the main form is to instantiate a new class like.
MyForm myform = new MyForm();
But when I do this, I loose the state (session) data.
When this _SelectedIndexchanged (ComboBox) fires, I need a way to get back into the main Form code so I can change the colors of certain columns.
I think there is a way to do this, I just don't know how. Thanks for any help...
| | |
Thanks a bunch!...that works just like I need it to. I hadn't thought of
that...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ux**************@TK2MSFTNGP14.phx.gbl... Randy,
Well, you have the data set available to you that you bind to the grid, right? Just find the table in the collection exposed by the Tables property on the data set, then attach to the ColumnChanged or ColumnChanging event.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... That sounds good...but I'm not sure how to do it. You got any examples?
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Randy,
The DataGridComboBoxColumn shouldn't be able to hook to the main form like that. Rather, why not attach the form to the events on the data source itself (the dataset) and detect when that column changes? When that happens, you can set the color appropriately on the grid.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Randy" <te**@temp.com> wrote in message news:OU**************@TK2MSFTNGP10.phx.gbl... Hello,
I've got a Form which has a dataGrid on it. In one of the columns of the dataGrid, I've implemented a ComboBox using a DataGridComboBoxColumn Class. I've also over ridden the other columns with a custom DataGridTextBoxColumn class so I can color certain columns.
What I'm trying to do is.based on the selection in the ComboBox, I want to color certain cells.
The problem I'm having is.when I make a selection in the ComboBox, the _SelectedIndexchanged event for the DataGridComboBoxColumn class fires like it should. At this point, when it fires, I'm in the DataGridComboBoxColumn class, not in the main Form class. The only way I know of to reference the main form is to instantiate a new class like.
MyForm myform = new MyForm();
But when I do this, I loose the state (session) data.
When this _SelectedIndexchanged (ComboBox) fires, I need a way to get back into the main Form code so I can change the colors of certain columns.
I think there is a way to do this, I just don't know how. Thanks for any help...
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by Gamze |
last post: by
|
3 posts
views
Thread by Bill C. |
last post: by
|
2 posts
views
Thread by john sutor |
last post: by
|
3 posts
views
Thread by PeterZ |
last post: by
|
2 posts
views
Thread by pei_world |
last post: by
|
3 posts
views
Thread by TT (Tom Tempelaere) |
last post: by
|
1 post
views
Thread by John Doe |
last post: by
|
reply
views
Thread by dbuchanan |
last post: by
|
1 post
views
Thread by fiaolle |
last post: by
|
4 posts
views
Thread by JJGarcia |
last post: by
| | | | | | | | | | |