These should be fairly easy questions:
1. I would like to draw a blue border around any cell that's been changed since the last update...what's the best way to do this?
2. I would like to change the forground color of the text in a cell if the first character is a ! - for example to indicate a phone number is disconnected !(123) 456-7890 would display in red
3. I have a fairly simple table with one column being a "status" this is an integer that relates to a status table (1=Active, 2=Inactive, 3=Dead). I'd like that column to be a combobox bound to column 1 of the status table, but displaying column 2.
4. Do I need to manually call a save function for the grid? I assume so, does it have a way I can determine if data is changed (ie OnClose() ...if ultrgrid1.DataIsDirty() then save...
Thanks for your help on this. This is my first adventure with ultragrid (having come from years and years of doinng stuff myself with ado in C++)
Peter
After spending quite soem time looking at all the functions for the grid, and extrapolating from the documentation on the webgrid (where is the docs for the winforms grid???) here is what I did...which is what I asked for in the first post:
private boolean bGridIsModified;private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ this.ultraGrid1.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ultraGrid1_UpdateCellEvent); bGridIsModified = false;}
public void ultraGrid1_UpdateCellEvent(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e){ e.Cell.Appearance.BackColor = System.Drawing.Color.LightSteelBlue; bGridIsModified = true; }
Now 2 days later...that wasn't so hard (he says sarcastically)
1. The UltraGridCell class exposes a DataChanged property, which (like the same property on UltraGridRow) returns whether the cell has pending changes.
4. No, you would have to iterate the Rows collection(s) and check the DataChanged property on each UltraGridRow.
1. Perhaps I should re-ask this question: How can I change the background color of a cell that has been modified? How can I tell which cell changed?
4. Is there a dirty flag for the grid...for example: if (ultragrid1.IsDataModifie()) { Prompt for save }
howudodat said: 1. Ok, I am now setting the background color using InitializeRow event. Is there a way to tell if just one cell changed? Right now I do: if (e.ReInitialize) e.Row.CellAppearance.BackColor = System.Drawing.Color.LightSteelBlue; but that sets the whole row
1. Ok, I am now setting the background color using InitializeRow event. Is there a way to tell if just one cell changed? Right now I do:
if (e.ReInitialize) e.Row.CellAppearance.BackColor = System.Drawing.Color.LightSteelBlue;
but that sets the whole row
You are setting the CellApearance on the Row. That affects all cells in the row. To affect an individual cell, you need to do something like this:
e.Row.Cells[columnKey].Appearance.BackColor = System.Drawing.Color.LightSteelBlue;
Also, I don't think you want to use e.ReInitialize here. The InitializeRow event fires quite often and this flag will be true every time but the first time for each row. This flag does not necessarily indicate anything about the state of the row except that is it being initialized again.
howudodat said: 2. Again I am using InitilializeRow. Here is how I set it. Is this the right way? Is there an event wizard? this.ultraGrid1.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.ultraGrid1_InitializeRow);
2. Again I am using InitilializeRow. Here is how I set it. Is this the right way? Is there an event wizard?
this.ultraGrid1.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.ultraGrid1_InitializeRow);
The Visual Studio property grid provides a list of events and creates event handlers for you for any control. This is nothing to do with the Infragistics controls. You should consult the Visual Studio documentation for more information.
howudodat said:3. HOWTO solved it!. However quick followup question. I now have 2 controls just placed orphaned on my form that the grid uses as editors. A CheckBox control, and ultrawindropdown. Both are set to hidden and are covered up by the ultragrid. However I can see how this could really clutter up a form in design time. Am I missing something here? I can't see any other way other than hand coding.
You could create the controls in code. Or just create editors instead of controls. Or, for most cases, you can probably just set the Style property on the column, rather than using an editor. It depends on the needs of your application.
Another option that I have used is to use an UltraWinTab control and set it's Style to Wizard. This gives you multiple tabs at design-time and run-time, but there is no UI at run-time.
howudodat said:4. Ok, so is there an event that I can use to set a dirty Boolean, or is there a built in dirty flag?
I'm afraid I do not understand your question.
3. HOWTO solved it!. However quick followup question. I now have 2 controls just placed orphaned on my form that the grid uses as editors. A CheckBox control, and ultrawindropdown. Both are set to hidden and are covered up by the ultragrid. However I can see how this could really clutter up a form in design time. Am I missing something here? I can't see any other way other than hand coding.
4. Ok, so is there an event that I can use to set a dirty Boolean, or is there a built in dirty flag?