I want to display negative values with a CR suffix, instead of a minus sign. How can I perform custom formatting on the cells in my datagrid
Take a look at this Microsoft KB article, HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data (Q318581). It subclasses a DataGridColumnStyle and overrides both GetColumnValueAtRow and Commit to implement this behavior.
I have a long loop. How can I make my application continue to process events while it is executing this loop
Call the static Application.DoEvents() method in your loop.
When I try to bind two comboboxes to the same datatable, both boxes show the same values, changing one changes the other. How do I make them have distinct values
Make sure the two comboboxes use different BindngContext objects. BindingContext bc = new BindingContext(); this.comboBox1.BindingContext = bc; comboBox1.DataSource = _dataSet.Tables[‘orders’]; comboBox1.ValueMember = ‘CustomerID’; comboBox1.DisplayMember = ‘CustomerID’; bc = new BindingContext(); this.comboBox2.BindingContext = bc; comboBox2.DataSource = _dataSet.Tables[‘orders’]; comboBox2.ValueMember = ‘CustomerID’; comboBox2.DisplayMember = ‘CustomerID’;
How can I get rid of the error icon that appears when there is an editing error
Adam Chester gives this solution in a posting on the microsoft.public.dotnet.framework.windowsforms newgroup. DataTable dt = (DataTable)dataGrid1.DataSource; foreach(DataRow row in dt.GetErrors()) { row.RowError = ”; foreach(DataColumn col in dt.Columns) row.SetColumnError(col, ”); }
How do I draw an image with a gray scale?
Here is some code: // Not the closest grayscale representation in the RGB space, but // pretty close. // Closest would be the cubic root of the product of the RGB colors, // but that cannot be represented in a ColorMatrix. public void DrawGrayedImage(Graphics g, Image image, int left, int top) { ImageAttributes ia = new ImageAttributes(); ColorMatrix cm = new ColorMatrix(); // 1/3 on the top 3 rows and 3 columns cm.Matrix00 = 1/3f; cm.Matrix01 = 1/3f; cm.Matrix02 = 1/3f; cm.Matrix10 = 1/3f; cm.Matrix11 = 1/3f; cm.Matrix12 = 1/3f; cm.Matrix20 = 1/3f; cm.Matrix21 = 1/3f; cm.Matrix22 = 1/3f; ia.SetColorMatrix(cm); g.DrawImage(image, new Rectangle(left, top, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, ia); }