Very Low Activity
6
I Use This!

News

Analyzed 2 days ago. based on code collected 2 days ago.
Posted 17 days ago by SoundOfMind
Zemira, Thanks for getting me started on resolving this issue. I understand how the Button.OnClick event works, but the CheckBox.CheckedChanged event does seem awkward. My solution was to modify the CheckBox.cs file as follows: Added: /// ... [More] /// An event MORE similar to Windows.Forms.CheckBox.CheckedChanged. /// Handled just like Button.OnClick, with sender argument containing CellContext /// Fired when value changed /// public event EventHandler CheckedChangedSenderCellContext; protected virtual void OnCheckedChangedSenderCellContext(object sender, EventArgs e) { if (CheckedChangedSenderCellContext != null) { CheckedChangedSenderCellContext(sender, e); } } Added the SECOND line shown (below existing line) in UIChangeChecked: OnCheckedChanged(EventArgs.Empty); OnCheckedChangedSenderCellContext(sender, e); Shown below is the modified frmSample03.cs. First is from the OnLoad handler: //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); SourceGrid.Cells.Controllers.CheckBox checkBoxClickEvent = new SourceGrid.Cells.Controllers.CheckBox(); checkBoxClickEvent.CheckedChangedSenderCellContext += new EventHandler(InvertDisabledCheckBox); grid[currentRow, 1].Controller.RemoveController(grid[currentRow, 1].FindController()); grid[currentRow, 1].Controller.AddController(checkBoxClickEvent); And last, the new InvertDisabledCheckBox: private void InvertDisabledCheckBox(object sender, EventArgs e) { SourceGrid.CellContext context = (SourceGrid.CellContext)sender; SourceGrid.Grid g = (SourceGrid.Grid)context.Grid; if (g != grid) return; int row = context.Position.Row; int col = context.Position.Column; grid[row, 2].Value = !(((bool)grid[row, 2].Value)); } Note that InvertDisabledCheckBox verifies that the grid in the context is the one you want. This allows use of multiple grids. I plan on submitting these changes to the project. Cal [Less]
Posted 20 days ago by cable08
Is there a way I can have columnspan for certain row but not others in DataGrid? Thanks in advance, Alex
Posted about 1 month ago by dooholee
I used usercontrol ComboBox in SurceGrid cells like bellow. But it's position was not on own cell. (actually, it going to right position after resige coloumns) and also how i can get control linked to surcegrid cells. This is my code : ... [More] grid1.LinkedControls.Add(new SourceGrid.LinkedControlValue(usedcontrol_marineColourCombo, new SourceGrid.Position(RowIndex, ColumIndex))) [Less]
Posted about 1 month ago by ksukat
Didn't see project example or documentation describing how to create a grid like the appointment grid shown on sourcegrid.codeplex.com. Anyone have any pointers ? Also, the install says to copy the sourcegrid.dll file. First I am using visual ... [More] studio 2010 professional. Second, the zip download doesn't seem to have that file. It has sourcegrid2.dll under sourcegrid project bin/release, should that be used ? If so, should that be copied to my project directory, or somewhere else? thanks. [Less]
Posted about 2 months ago by brightak
And the hits keep coming. So, SourceGrid does have a DrapDrop event, you just have to remember to enable AllowDrop (ooops). void MyGrid_DragDrop(object sender, DragEventArgs e) { Point p = ... [More] this.PointToClient(new Point(e.X, e.Y)); int _X = this.Location.X; int _Y = this.Location.Y; int c = -1; int r = -1; while (_X < p.X) _X += this.Columns[++c].Width; while (_Y < p.Y) _Y += this.Rows[++r].Height; //Selected cell is this[r, c]. Console.WriteLine(" row = " + r + " col = " + c); } [Less]
Posted about 2 months ago by brightak
I spoke too soon. MouseUp doesn't help if you're dragging and dropping. In case you were curious, here is my Hittest solution: int _MouseX = e.Location.X; int _MouseY = e.Location.Y; int _X = ... [More] this.Location.X; int _Y = this.Location.Y; int c = -1; int r = -1; while (_X < _MouseX) _X += this.Columns[++c].Width; while (_Y < _MouseY) _Y += this.Rows[++r].Height; //Selected cell is this[r, c]. Console.WriteLine(" row = " + r + " col = " + c); [Less]
Posted about 2 months ago by brightak
I get that SourceGrid does not support a DropDrop event (booo!) but it does support a MouseUp event. If I can figure out which cell is being dropped to, I'm almost home. Any ideas? Thanks in advance.
Posted about 2 months ago by BitterBiped
Hi, I am making the transition from SourceGrid 2 to SourceGrid 4. I need to validate a cells value before the cell's Edit Ended is called. The IController does not have an equivalent OnEditEnding for OnEditStarting. So there seems to be no way ... [More] to cancel an edit end event if the value is not valid. In SourceGrid 2 I could attach a SourceGrid2.PositionCancelEventHandler onto the BehavioulModel EditEnded event, and set Cancel = true, but I do not know how to do this in SourceGrid 4. Can anyone help? Thanks. [Less]
Posted 2 months ago by mikey0727
Hi - I have a sourcegrid datagrid with a table behind it. I have multiple threads (4) updating the backing table, and so - thus I have 2 copies of the table, and merge them from the UI thread. Some things to note: The table is guarded by a ... [More] readerwritterlockslim. Lock contention doesn't seem to be an issue. There is no database behind this table, its for display purposes only. Only columns 3 or 4 can change during the times I care about performance- With about 8000 rows, I see merge times (used high precision stopwatch to measure) of about 150 milliseconds average, 800 worst case when lots of cells change. Would an arrayGrid be better here? Every column in the table does not have the same type, so I'm unsure how to do it properly; I played with suspend / resume layout and Invalidate Range / Update (as shown below) but I saw worse results. Thanks for any tips / input - Code looks like the following: Each Thread is doing this to update their rows - private void UpdateGridStatusDataTableRow(int rowIndex, string stateString, string directionString) { _gridTableSlimLock.EnterWriteLock(); DataRow row = _gridDatasetStatusTable.Rows[rowIndex]; row.BeginEdit(); row[3] = stateString; row[4] = directionString; row.EndEdit(); _gridTableSlimLock.ExitWriteLock(); } About once per second, the merge is called from the main UI thread - public void RefreshGrid() { //expSetGrid.SuspendLayout(); //expSetGrid.InvalidateRange(new Range(0, 3, _lastRow, 4)); _experimentSet.MergeGridStatusDataTable(_gridSource); //expSetGrid.Update(); //expSetGrid.ResumeLayout(false); } public void MergeGridStatusDataTable(DataTable uiDatatable) { _gridTableSlimLock.EnterWriteLock(); uiDatatable.Merge(_gridDatasetStatusTable, false); //_gridDatasetStatusTable.AcceptChanges(); _gridTableSlimLock.ExitWriteLock(); } The Grid is Initialized as follows: //Disable Constraints _gridSource.Constraints.Clear(); //DataTable _view = _gridSource.DefaultView; //DataView _view.AllowEdit = false; _view.AllowDelete = false; _view.AllowNew = false; _bdv = new BoundDataView(_view); //BoundDataView expSetGrid.DataSource = _bdv; //SourceGrid.DataGrid [Less]
Posted 3 months ago by Flanter
I have created new WinForms application and added reference to SourceGrid.dll. Then I added the Form.Load event handler: // Just some constants from my project private int cols_count = 5; private int col_number = 0; private int col_contract = 1; ... [More] private int col_period_total = 2; private int col_period_current = 3; private int col_period_diff = 4; private void Form1_Load(object sender, EventArgs e) { g = new Grid(); g.Parent = this; g.Dock = DockStyle.Fill; g.RowsCount = 2; g.FixedColumns = cols_count; g.ColumnsCount = cols_count; // Some fixed cells g.Rows.Insert(0); g.Rows.Insert(1); g[0, col_number] = new SourceGrid.Cells.ColumnHeader("#"); g[0, col_contract] = new SourceGrid.Cells.ColumnHeader("Contract"); g[0, col_period_total] = new SourceGrid.Cells.ColumnHeader("Sum"); g[0, col_period_current] = new SourceGrid.Cells.ColumnHeader("Out"); g[0, col_period_diff] = new SourceGrid.Cells.ColumnHeader("Int"); for (int i = 0; i < cols_count; i ) g[0, i].RowSpan = 2; g.Columns[col_number].Width = 30; g.Columns[col_contract].Width = 200; g.Columns[col_period_total].Width = 80; g.Columns[col_period_current].Width = 80; g.Columns[col_period_diff].Width = 80; for (int i = 0; i < 10; i ) { int n = cols_count i; g.Columns.Insert(n); // Every five columns will have common header if (i % 5 == 0) g[0, n] = new SourceGrid.Cells.ColumnHeader("dep " i.ToString()); g[1, n] = new SourceGrid.Cells.ColumnHeader(i.ToString()); g.Columns[n].Width = 35; } // // HERE I TRY TO COMBINE FIVE COLUMNS IN FIRST ROW // UNCOMMENT ONE OF THE FOLLOWING LINES // //g[0, 5].ColumnSpan = 4; // THIS WORKS, but one cell is not in group //g[0, 5].ColumnSpan = 5; // THIS WON'T, crashes with exception } Maybe I just do something wrong here... but I stuck with this exception for two days already... I use VS 2012 Express for Desktop. [Less]