I need to save a color as a string and be able to retrieve it. How can I do this

Here are a couple of routines that might do what you want. ColorToString takes a color and represents it as a string that then can be passed into its companion StringToColor routine that will take the string back into a color. I think it works with all types of colors. You can download a test project. public string ColorToString(Color c) { string s = c.ToString(); s = s.Split(new char[]{’[’,’]’})[1]; string[] strings = s.Split(new char[]{’=’,’,’}); if(strings.GetLength(0) > 7) { s = strings[1] + ”,” + strings[3] + ”,” + strings[5] + ”,” + strings[7]; } return s; } public Color StringToColor(string s) { return (Color)TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString(s); }

Are AutoScrolling bounds setup in World or Device coordinates

AutoScrollingMinSize is setup in device coordinates. If you are using a world coordinate system other than pixels this means that you have to translate between world and device coordinates before you set these value. You can use the Graphics.TransformPoints API to do this as shown below. g.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, ptScrollSize); All this does is go from the GraphicsUnit that you are using to pixels. For example if your GraphicsUnit is Inch, then with a Graphics object that represents a monitor screen you will have translated values that come to about 100 pixels for every logical inch. Using this API ensures that you are insulated from the underlying device. The values will be much higher for printers. Another important point to remember is that your Transform in the painting code (please refer earlier FAQ in this section on AutoScrolling implementation) will have to be in logical coordinates and will hence have to translate between logical and device coordinates. protected void OnHandlePaint(object sender, PaintEventArgs args) { Graphics g = args.Graphics; g.PageUnit = GraphicsUnit.Inch; // this will always be in pixels Point[] ptAutoScrollPos = new Point[]{this.AutoScrollPosition}; // We have to convert the pixel value (device) to inches (logical..world) g.TransformPoints(CoordinateSpace.World, CoordinateSpace.Device, ptAutoScrollPos); // set up a simple translation so that we draw with respect to the doc bounds // and not the physical bounds g.TranslateTransform(ptAutoScrollPos[0].X, ptAutoScrollPos[0].Y); g.DrawEllipse(_pen, _rectEllipse); } Play around with the sample and all should be clear. When you run the sample nothing will be seen on the screen. Scroll around. Remember the logical units are in inches. You will be looking at a huge ellipse! Source: Syncfusion Staff

How can I tell if the current row has changed and whether I am on the AddNew row or not

The DataGrid’s CurrentCellChanged event is hit even if you just change cells in the current row. If you want an event that is only hit when you change rows, then you have to look at the binding manager. This object has both a CurrentChanged event and a PositionChanged event which are hit when you change rows. To decide whether you are on the AddNew row or not, you can again use the binding manager and compare the number of rows it returns with the number of rows in your data table. Below is some code snippets showing how you might get at this information. private System.Windows.Forms.DataGrid dataGrid1; private BindingManagerBase bindingManager; private void Form1_Load(object sender, System.EventArgs e) { // Creating connection and command sting string conStr = @’Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb’; string sqlStr = ‘SELECT * FROM Employees’; // Create connection object OleDbConnection conn = new OleDbConnection(conStr); // Create data adapter object OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn); // Create a dataset object and fill with data using data adapter’s Fill method DataSet ds = new DataSet(); da.Fill(ds, ‘Employees’); dataGrid1.DataSource = ds.Tables[‘Employees’]; bindingManager = this.BindingContext[dataGrid1.DataSource]; bindingManager.PositionChanged += new System.EventHandler(RowChanged); } private void RowChanged(object sender, System.EventArgs e) { Console.WriteLine(‘RowChanged ‘ + bindingManager.Position.ToString() ); bool lastRow = bindingManager.Count > ((DataTable)dataGrid1.DataSource).Rows.Count; if(lastRow) Console.WriteLine(‘lastRow’); }