| Problem with RowChanging event |
|
 |
Index ‹ Windows Forms ‹ Windows Forms Data Controls and Databinding
|
- Previous
- 1
- Windows Forms General Putting text on an image on a form
I am an old C/C++ programmer that is trying to learn C# and .net. I need to take text from a .txt file and display it on a form in graphics. I eventually need to save the image to a .jpg file.
I created a picturebox (is this the right object to use ) on the main form, opened the .txt file and read in one line at a time. Now I need to put each line of the text into the picturebox area in graphics mode to display it on the screen in the same order as the text in the file.
Any suggestions
Thank you
OldCDude
- 2
- Windows Forms General Form Opacity Changed -> Component not updatingFirst of all I apollogise for reposting this, but apparently I haven't posted it in the right place the first time. I hope that by posting here I could get an answer. So here goes:
I have created a form, and set the region of the form from a bitmap. On this form I have an PictureBox Component wich is updated by a timer. On the OnTimer Event I have some code that does the following things :
- Gets a region of the forms background and paints it on the control
- Gets 2 bitmaps from two different picture boxes and draws them on control
Everything worked fine until I decided to add the possibility to change the forms Opacity at runtime. The form is shown with 100% opacity at runtime and everything works as it should. When I change the opacity :
this ->Opacity = 0.7;
the form is made semi-transparent but the PictureBox stops updating. The odd thing is that when I hold the left mouse button pressed on the form, the control updates as it should.
I should mention that I have the following code, which is used to move the form, in the OnMouseDown event of the form :
int WM_NCLBUTTONDOWN = 0xA1;
int HT_CAPTION = 0x2;
Win32Calls::ReleaseCapture();
Win32Calls::SendMessage( this->Handle,WM_NCLBUTTONDOWN,HT_CAPTION,0);
I've tried forcing a form redraw at each update, but aside the flicker that it creates on each timer update, when the form is first shown, it has no effect whatsoever when the opacity is changed. One last thing I should mention is that when I change at runtime the Opacity from anything to 100% things work once again.
Thank you for your answers, Dragos
- 3
- Windows Forms Data Controls and Databinding combobox selectedvalue vs text question
Is there one method for getting a value in a comboxbox (DropDownStyle set to DropDown) regardless of whether the user entered or selected a value. My combobox is initially populated with a datatable and has a Value and Display member. Since a user can enter thier own value, it would not have a ValueMember, therefore SelectedValue fails. It seems I may have to test the SelectedValue and the Text properties for both validation and saving the data. I was hoping there would be an easier way.
Also, I just noticed that I may not be able to use the DataBinding properties from my bindingsource because if I bind using the SelectedValue, if the value isn't in the list then it doesn't show up. If I use the Text, everything works but I can't leave the control, let alone close the form. It seems to get hung.
- 4
- 5
- 6
- ClickOnce and Setup & Deployment Projects validate a serial number from a DLL I am trying to get my project to validate a serial number using a DLL or EXE file I have written instead of the included algorithm, but I have no clue how to get the Customer Information dialog to read from a DLL or EXE file or if it is even possible. I have searched through other threads and haven't found anything extremely useful. I am using Visual Basic .NET and Visual Studio .NET 2003. Can anyone help me with this
- 7
- 8
- Windows Forms Data Controls and Databinding Need some Datagrid help
I have datagrid wih two colums, Name & Role. I just want to the show the datagrid that there role is A. In that column I have a ddl_role list.
if (dgUsersAd.Columns.Equals("A")) //if(dgUsersAd.Columns[1].InitializeCell) { daUsers.Fill(dsUsers1.users); dgUsersAd.DataBind(); } else { lbl_mes.Text = "NO Admin Users".ToString(); }
I tried it this way..but it is not working.
- 9
- Windows Forms Data Controls and Databinding cannot view data in datagridview
I've tried using the code below to view data from a select query in a datagridview control (along with several other methods) with no success. It is slightly adapted from a BOL example. The bindingnavigator appears to be reading the bindingsource ok (shows correct number of records) however, the datagridview remains blank.
Private Sub GetData(ByVal selectCommand As String, ByVal connectionString As String)
Dim VwTblDataAdapter As SqlDataAdapter
Try
' Create a new data adapter based on the specified query.
VwTblDataAdapter = New SqlDataAdapter(selectCommand, connectionString)
' Create a command builder to generate SQL update, insert, and
' delete commands based on selectCommand. These are used to
' update the database.
Dim commandBuilder As New SqlCommandBuilder(VwTblDataAdapter)
' Populate a new data table and bind it to the BindingSource.
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
VwTblDataAdapter.Fill(table)
Me.BindingSource2.DataSource = table
' Resize the DataGridView columns to fit the newly loaded content.
Me.DataGridView2.AutoResizeColumns( _
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)
Catch ex As SqlException
MessageBox.Show( "To run this example, replace the value of the " + _
"connectionString variable with a connection string that is " + _
"valid for your system.")
End Try
End Sub
- 10
- 11
- 12
- Windows Forms General PictureBox control question.
Is it possible to open a multipage Tiff file using the .net 2.0 PictureBox control If not cananyone reccomend a reliable ( and prefferably cheap ) 3rd party control that will
Any help is greatly appreciated!!!
- 13
- 14
- ClickOnce and Setup & Deployment Projects Deploying a windows-based applicationI tried to deploy a walkthrough Called " My Notepad" under the title "Walkthrough: Deploying a windows-base application". When I wanted to build the project it failed. It gave me an Error message in the Error Pane saying " Unrecoverable error. I tried several times but I got the same result. I followed the steps accurately. What is the solution Thanks.
- 15
- Windows Forms Data Controls and Databinding List Of Objects As DataSource for DataGridView and DataGridViewComboBoxColumn
Hi all,
I have a DataGridViewComboBoxColumn:
Dim cbCol As New DataGridViewComboBoxColumn
With cbCol
.DataSource = myCatalogoPOS.SubMenus() 'Private _submenus As New List(Of SubMenu)
.ValueMember = "Clave"
.DisplayMember = "Nombre"
End With
------------------------------------------------------------------------------------------------------------------
The DataSource for cbCol is a List of this Class
Public Class SubMenu
# Region "Miembros Privados"
Private _clave As Integer
Private _nombre As String
-----------------------------------------------------------------------------------------------------------------
Also I have a DataGridView(dgvMenu) with its DataSource Property set to:
Using myCatalogoPOS As New CatalogoPOS
With Me.dgvMenu
.DataSource = myCatalogoPOS.Platillos() 'Private _platillos As New List(Of Platillo)
'Insert the cbCol
.Columns.Insert(4, cbCol)
.....
-------------------------------------------------------------------------------------------------------------------------
The DataSource for dgvMenu is a List of this Class
Public Class Platillo
# Region "Miembros Privados"
Private _clave As Integer
Private _nombre As String
Private _nombreboton As String
Private _nombrelargo As String
Private _taxid As Integer
Private _routing As Integer
Private _costo As Double
Private _modificadores() As String
Private _submenu As Integer
Private _precio As Double
.....
---------------------------------------------------------------------------------------------------------------------
How can I make the default value (of every row) for the cbCol of the dgvMenu to be the value of the SubMenu(_submenu) Property of the Platillo Class
|
| Author |
Message |
ManniAT

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi,
if have a DataSet (SQLExpress) whith 2 Tables. On one table I add a RowChanging event handler. When I add a record in a boud datagridview then an exception occures in the handler. (After changing the postion in the DGV the event is fired). Here my handler:
| | void PCs_RowChanging(object sender, DataRowChangeEventArgs e) { if (PCsBindingSource.IsBindingSuspended) { return; } try { MessageBox.Show(e.Action.ToString()); } catch(Exception eX) { MessageBox.Show(eX.Message); } } |
I get and "Index out of range" exception and my DGV is a red rectangle with red lines across it. After the exception I can see my MessageBox telling "Add". For changes the things work fine - but the Add makes problems if I show the Messgebox - if I do nothing (comment out the messagebox)- no problems occure! The error comes up even if I only call MessageBox.Show("Hello");
Here is the stacktrace of the error:
************** Exception Text ************** System.IndexOutOfRangeException: Index 2 does not have a value. at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(Int32 rowIndex) at System.Windows.Forms.DataGridViewRow.GetErrorText(Int32 rowIndex) at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow) at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded) at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded) at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.DataGridView.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is this a bug - or do I miss something
Cheers
Manfred
Windows Forms34
|
| |
|
| |
 |
durstin

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi Manfred, I'm afraid I can't replicate your error. I was able to add a row on my DGV whose Table had a RowChanging event attached, per your code. No problems... Can you post a simple project that replicates the problem
|
| |
|
| |
 |
ManniAT

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi Durstin,
I reduced the things to the minimum. This means I use the local SQLEXPRESS instance, and added only 2 lines of code to a new project! To produce the error I just have to inster a new row. After entering the last field, I press key down to come to the next (new) record - that's it.
To run the project (without changes) your need a local SQLEXPRESS with the pubs database. Nothing more. Since I see no way here to attach something - i placed it on one of our servers: http://ttncf.pp-p.com/TestGridError.zip
----- An other (maybe the same source) problem occured. In "Rowchanged" I add
| | try { theBindingSource.SuspendBinding(); //here is normaly code - but not neede for the error return; } finally{ theBindingSource.ResumeBinding(); }
|
With this code I get an error - but only if I: a.) add a record b.) use the keyboard (down arrow) to navigate to the next (new) row
This error tells "index out of range" in OnPaint of the grid. I can tell continue - the everything is OK. When I use the mouse - this error does NOT appear!!
Cheers
Manfred
|
| |
|
| |
 |
durstin

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Thanks Manfred. I have replicated the problem and am looking into it.
|
| |
|
| |
 |
john cov

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi --
I am having a very similar issue, but I haven't found a solution.
I have a highly customized DataGrid -- when I use the delete key to delete certain rows, in the DataGridRow.PaintRowHeader, the same exception as above occurs.
Googling around, I found that this happens when CurrencyManager.Current is invalid ( apparently). Unfortunately, I have no idea how to prevent this.
Hoping you find something durstin! ~John
|
| |
|
| |
 |
ManniAT

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi John,
maybe it helps - but I don't need the ChangING event the ChangED is enough for me. And there I use my own boolean instead of SusbpendBinding - with this no error occures.
Cheers
Manfred
|
| |
|
| |
 |
durstin

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
We are looking into this, but do you encounter the error only when using MessageBox. If so, try using Debug.WriteLine or some other feeback method than MessageBox.
|
| |
|
| |
 |
ManniAT

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
Hi Durstin,
I encouter the error alos when I call a webservice for an example. This means "lengthy" operations seem to make problems. The MessageBox was an example with which the error is 100% redproducalbe. I found it by checking for errors - and I choose this way since a.) debugging against a server with hostheader evaluation (and more sites) fails b.) local debugging would work but the developer werbserver maps to a subdir -- ---my web is rootbound - so paths like /images/xxx.ashx fail in the developer webserver
BUT - as I told above I can go on with the RowChanged event - and this one does not break if I avoid SuppressBinding and use a private bool instead.
So the problem is not stopping me work.
Thanks for your help
Manfred
|
| |
|
| |
 |
Joe Stegman

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
This appears to be a bug. The message box is causing the DataGridView to paint at a time when it expects the new row to have already been committed. I have logged a bug against this issue however if you want to track this, you can enter a bug using the link below and we'll link you're bug to the one I've already entered.
Joe
http://lab.msdn.microsoft.com/productfeedback/Default.aspx
|
| |
|
| |
 |
ManniAT

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
|
| |
 |
Kurt Place

|
Posted: Windows Forms Data Controls and Databinding, Problem with RowChanging event |
Top |
I had the same (similar problem with DataGrid) where I deleted the last row, then without clicking on any rows I click on the vscrollbar. I get the IndexOutOfRangeException also. then I saw the comment from John Cov where the Current was invalid. So at the end of my delete function I set the CurrencyManager.Position to a valid row. Now the scroll click does not error out.
Kurt
|
| |
|
| |
 |
| |
 |
Index ‹ Windows Forms ‹ Windows Forms Data Controls and Databinding |
- Next
- 1
- Windows Forms General Help with new programI need help with a program I am intending to do. Using C# obviously.
This program will display messages every 30 minutes (for example), and disappear after a few seconds. The messages will be stored in some dedicate folder.
So, in order to do that, how do you: 1) convert the C# program to a .msi or .exe for installation 2) operate in the background, and displaying the program icon in the windows tray icon 3) pop-up the messages every 30 minutes and hide it after a few seconds 4) start the program when window starts
As you can see, i'm very new at C#, and have never done anything this complicated in C#. So, much help will be needed and appreciated. Thanks.
- 2
- Windows Forms General Replace string
i have a string "12:12:2006" and i wanted to remove ":" in the string.
I tryed stringname.Replace(":","") but it dosen't work.Can any one help me in this.
- 3
- Windows Forms General RichtextBox - AllowDrop vs. EnableAutoDragDrop
I'm trying to implement drag and drop between a RichTextbox and formatted text in a Word document.
I have placed a System.Windows.Forms.Richtextbox on a VB.Net usercontrol, and am displaying it on an Actions Pane so that it is available in a Word document.
All documentation I have seen points to an AllowDrop property on a RichtextBox, but I am not seeing this property in the design time window for the control. (I can, however, set the .AllowDrop property to True when the form is loaded).
Confusing me further, I am seeing a design time property called EnableAutoDragDrop (w/little or no documentation on this one).
Can someone clear me up on the difference between the two, and which one would be more useful for my purposes
Thank you
- 4
- Windows Forms Data Controls and Databinding Need DataGridView Read/Write Example ComboBoxVB2005, SQL Server 2000
The MS supplied 101 sample DataGridView ComboBoxColumn example is read only which is kinda dumb since I'm not sure when one would ever need a read only dropdown.
Has anyone seen a KISS example of connecting to a SQL Server 2000 table (spmething like the PUBS DB, authors table) using a DataGridView with a combo, say on the State field Need to see something that does not use the DataSource wizard objects.
In general: Is it possible to bind to a dataset using the auto generated columns and then change a column type to Combo Or does one have to construct all columns manually if any are other than the auto generated type
TIA
- 5
- 6
- Windows Forms General Combobox.Text unexpected behavior (C#)(C#, VS 2005) I have a Combobox (free typing + preset options) that is
used to enter a name. On it's Validated Event I want to check if the
name already exists in the (Array)List. If it does, I want to change
the text of the combobox back to the old value. The code is something
like this:
string oldName =
ListOfNames[0]; string newName = myCombobox.Text; if(ListOfNames.Contains(newName) { MessageBox.Show("Name already exists in the list."); myCombobox.Text = oldName; } else { ListOfNames[0] = newName; }</code>
It doesn't work the way I want it to. When It
validates and the name already exists, the messagebox pops up, the name
is changed back, but quickly changed back again (newName &gt;
oldName &gt; newName). The oldName is not visible to the eye
because it is immideatly changed again. Then, when you validate again
(right after the first try) it works fine. Any help is
appreciated.
- 7
- 8
- Windows Forms General Urgent: NullReferenceException on the RenderControl method of the new Treeview web server control
I get a NullReferenceException on the RenderControl method of the new Treeview web server control for ASP.NET version 2.0.
The exception message is: "Object reference not set to an instance of an object."
The stack trace is: "at System.Web.UI.WebControls.TreeView.GetImageUrl(Int32 index)\r\n at System.Web.UI.WebControls.TreeNode.Render(HtmlTextWriter writer, Int32 position, Boolean[] isLast, Boolean enabled)\r\n at System.Web.UI.WebControls.TreeView.RenderContents(HtmlTextWriter writer)\r\n at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)\r\n at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)\r\n at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)\r\n at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)\r\n at dmgTools.UserInterFace.Web_Controls.WebTabControl.RenderTabs() in C:\\Projects\\Source\\Framework\\UserInterface\\Web Controls\\WebTabControl\\WebTabControl.cs:line 310"
Other posts have suggested setting the SkipLinkText property of the Treeview to "". I have done this but it doesn't help. I found that setting the ShowExpandCollapse property to false lets me run the RenderControl method but I need it to be true so I can navigate through the child nodes. I tried setting the ExpandImageUrl and CollapseImageUrl properties and setting ImageSet="custom" but this didn't help. I have run out of ideas. Can someone please help (maybe someone from Microsoft) This is really urgent.
Thanks,
Lance
- 9
- Windows Forms General Switching between Console application and Windows Forms applicationsI was hoping to write a single application that can behave as Console application if specific run parameters are specified and behave as Windows Forms application otherwise (of course without the Console).
For example: public static void main(string[] args) { if(//check if args has specific run params) { //do stuff Console.WriteLine(//results); return; } else { //Show nice form and all that } }
Couldn't find any pointers as to how to achieve this.
Any pointers
Mad.Earth
- 10
- 11
- 12
- Windows Forms Data Controls and Databinding Problem with DataGrid column width
I am working on DataGrid (VS 2003) and I am having problem with width of the columns.
I have added the DataGridTableStyle and DataGridColumnStyles to the DataGrid for each column. I have adjusted the width of each of the columns so that the total width of the columns equals the width of the DataGrid. My main intension is not to leave any area on the DataGrid blank.
Everything was fine on my machine but when I ran that application on another machine, the columns were not occupying the entire DataGrid area.
How do I make it same on all the machines
I appreciate any help!
Thanks Basani
- 13
- 14
- Windows Forms General Switching between Console application and Windows Forms applicationsyI was hoping to write a single application that can behave as Console application if specific run parameters are specified and behave as Windows Forms application otherwise (of course without the Console).
For example: public static void main(string[] args) { if(//check if args has specific run params) { //do stuff Console.WriteLine(//results); return; } else { //Show nice form and all that } }
Couldn't find any pointers as to how to achieve this.
Any pointers
Mad.Earth
- 15
- ClickOnce and Setup & Deployment Projects Licensing and User Counts
I distribute software that I write and would like to accomplish two things:
(1) Produce a 'license key' for the user, so they cannot copy the application from someone else and use it. Perhaps a key based on the server domain or IP address.
(2) In the App.config file put some encrypted key that indicates the number of users permitted. I will then compare this to the total number of users added to a Users table to manage the license restrictions. (I license based on number of users defined, not concurrent users).
Thanks.
|
|
|