|
Hey, I am new to GUI programming
While trying to design a dialog box that gets user input and saves it to a file on clicking the save button, I ran into this error.
[code]
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System;
public class Mfury : Form
{
public Mfury()
{
Size = new Size(800,500);
Text = "Enter details of the book";
Label xo = new Label();
xo.Text = "Name : ";
xo.Location = new Point(10,10);
xo.Width = 50;
xo.Parent = this;
TextBox to = new TextBox();
to.Parent = this;
to.Location = new Point(90,10);
to.Width = 600;
to.Multiline = false;
string Var1 = to.Text;
Label x1 = new Label();
x1.Text = " ISBN : ";
x1.Width = 50;
x1.Location = new Point(10,50);
x1.Parent = this;
TextBox t1 = new TextBox();
t1.Parent = this;
t1.Location = new Point(91,43);
t1.Width = 600;
t1.Multiline = false;
string Var2 = t1.Text;
Label x2 = new Label();
x2.Text = "Key Words :";
x2.Width = 80;
x2.Parent = this;
x2.Location = new Point(10,90);
TextBox t2 = new TextBox();
t2.Parent = this;
t2.Location = new Point(91,83);
t2.Width = 600;
t2.Multiline = false;
string Var3 = t2.Text;
Button bo = new Button();
Button b1 = new Button();
bo.Parent = this;
b1.Parent = this;
bo.Location = new Point(520,350);
bo.Text = "Save";
bo.Height = 100;
bo.Width = 100;
Controls.Add(bo);
b1.Location = new Point(630,350);
b1.Text = "Close";
b1.Size = new Size(100,100);
Controls.Add(b1);
bo.Click += new EventHandler(onsave);
b1.Click += new EventHandler(onExit);
}
void onsave(Object Sender,EventArgs e)
{
FileStream fs = new FileStream("test.txt",FileMode.OpenOrCreate,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(to.Text);
sw.WriteLine(t1.Text);
sw.WriteLine(t2.Text);
sw.Close();
}
void onExit(Object Sender,EventArgs e)
{
Close();
}
public static void Main()
{
Application.Run(new Mfury());
}
}
[\code]
|
|
|
|
|
What error, and where does it occur? Also, please use <pre> tags around your code, not [code] . You can do it automatically by selecting all the lines in your post, and using the code button at the top of the edit box.
|
|
|
|
|
An easy idea would be, "you need to create a variable with that name, or you need to see if variable name has any typos".
Secondly, as already mentioned. [code][\code] is supported on some websites, such as Quora. On CodeProject, you have to embed your code inside <pre> tags, or you can try out using the new Markdown[^] on CodeProject.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hello;
I am seeking a joystick-alike windows forms control that is free to implement some directional mooving in my windows form..with no success.
please can any one help me find this.
|
|
|
|
|
|
Hi, I have a gridview where the first column is a checkbox. When I open the grid, the value of the first checkbox is always false, no matter how it is initialized. When I select another cell, the correct state appears. How could I have the correct value be shown?
|
|
|
|
|
Without seeing some of your code it is impossible to guess why this may be happening. How do you initialise the checkbox?
|
|
|
|
|
ok, here is my intitialization:
foreach (Linie lrow in ud.Linien)
{
LLinGrid.Rows.Add();
DataGridViewRow gr = LLinGrid.Rows[LLinGrid.NewRowIndex - 1];
gr.Cells["global"].Value = Convert.ToString(lrow.Global);
gr.Cells["ust"].Value = Convert.ToString(lrow.Ust);
gr.Cells["kennung"].Value = Convert.ToString(lrow.Kennung);
if ((lrow.Kennung & 0x80) != 0)
gr.Cells["isuz"].Value = true;
if ((lrow.Kennung & 0x40) != 0)
gr.Cells["aktiv"].Value = true;
gr.Cells["dir"].Value = Convert.ToString(lrow.Dir);
gr.Cells["xmit"].Value = true;
}
if I move the "xmit" column from position 1 to >2, it works. I tried:
LLinGrid.ClearSelection();
LLinGrid.Rows[0].Cells[1].Selected = true;
LLinGrid.Invalidate();
LLinGrid.InvalidateCell(LLinGrid.Rows[0].Cells[0]);
LLinGrid.Show();
LLinGrid.UpdateCellValue(0, 0);
All of those didn't show the desired result. The value for the checkbox in the first column stays unchecked until I move to the next cell.
this happens only in the first row; follwing rows are correct.
|
|
|
|
|
Got it. I had
this.Show();
positioned before the initialization block above. This raises the BeginEdit event for the first cell which seems to prevent the altering via program.
There are 2 ways to solve this:
move
this.Show();
or insert
LLinGrid.EndEdit();
behind initialization,
Thanx for your interest.
|
|
|
|
|
|
Windows Forms do not really lend themselves too well to such design. Try WPF which offers much more flexibility of layout.
|
|
|
|
|
You GDI things on the Device Contexts provided by the forms. I personally prefer this approach to WPF.
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Hello all,
Hopefully I am posting in the right place otherwise please correct me.
I want to display a scrollable list of tiles with images to display categories of items (all click selectable) and have another area displaying products as images all click selectable. I want to do this in C# .net 4.0 using VS 2010.
I would like advice on which controls to use from the basics (non commercial please). Could someone please point me in the right direction.
Like the layout shown here
http://unicenta-opos.en.softonic.com/[^]
I have looked at a few things ??
|
|
|
|
|
minnie mouse wrote: I want to do this in C# Then you would probably get a better response in the C# forum. However, the control you need will most likely be a ListView[^].
|
|
|
|
|
Hey guys, we are trying to design an autonomous system to match the criteria between college students qualifications and the companies offering intern positions requirements, I have checked and the closest thing I got were a few CRM's. If any of you have any idea about any open source software that we can use to design such a system please share your knowledge on the matter 
|
|
|
|
|
this i my first post, so i hope i am explaining it correctly, have a datagridview with a textboxcolumn. it is bind to a dataset
my problem is when i update a record wiht more that 350 characters it give me a nullrefference error. the database is updated when i check the physical record but the application crash
here is the function
Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated
Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable
Try
If e.Data.Contains("ModifiedRows") = False Then Exit Sub
tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable)
If tempTable.Rows.Count > 0 Then
RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated
Processor.Data.WebsitePageDownload.LoadingTable = True
Processor.Data.WebsitePageDownload.Merge(tempTable, False)
Processor.Data.WebsitePageDownload.LoadingTable = False
Processor.Data.WebsitePageDownload.RejectChanges()
AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated
Processor.Data.WebsitePageDownload.Merge(tempTable)
'For Each row As DataRow In tempTable.Rows
' If row.RowError IsNot Nothing AndAlso row.RowError.Length > 0 Then
' MsgBox(row.RowError)
' End If
' ' MsgBox(row("URL").ToString)
'Next
'MsgBox(Processor.Data.WebsitePageDownload.Columns("defaultstatusid").MaxLength)
Processor.Data.WebsitePageDownload.AcceptChanges()
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
tempTable = Nothing
Me.StatusMessage = String.Empty
End Sub
error gets thrown on acceptchanges
|
|
|
|
|
Where does the error occur?
Please edit your question and put <pre> tags around your code so it looks like:
Processor.Data.WebsitePageDownload.RejectChanges()
AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated
and indicate exactly which line the error occurs on.
|
|
|
|
|
 Thanks for your response. The error occur on the acceptchanges line
Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated
Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable
Try
If e.Data.Contains("ModifiedRows") = False Then Exit Sub
tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable)
If tempTable.Rows.Count > 0 Then
RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated
Processor.Data.WebsitePageDownload.LoadingTable = True
Processor.Data.WebsitePageDownload.Merge(tempTable, False)
Processor.Data.WebsitePageDownload.LoadingTable = False
Processor.Data.WebsitePageDownload.RejectChanges()
AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated
Processor.Data.WebsitePageDownload.Merge(tempTable)
Processor.Data.WebsitePageDownload.AcceptChanges()
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
tempTable = Nothing
Me.StatusMessage = String.Empty
End Sub
|
|
|
|
|
You will need to use your debugger to find out which reference in that line is invalid.
|
|
|
|
|
what i know for a fact is the is a field that is set for 2000 characters but once this field goes over 350 the error gets triggered, other than that the application is fine
|
|
|
|
|
Rhyde Marsh wrote: what i know for a fact But that is hardly relevant. Somewhere in your application something is being triggered which causes a null reference to be used. The only way to discover where that is and why, is to do some detailed debugging.
|
|
|
|
|
ok i will get to that. juss that i have been looking and and dont see where
|
|
|
|
|
2000 characters? In which encoding? UTF16?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
sorry for the late response but data field is set to nvarchar 2000
and the MaxInputLength set at 2000
|
|
|
|
|
Rhyde Marsh wrote: nvarchar Good.
Check the line
Processor.Data.WebsitePageDownload.AcceptChanges() Set the cursor on the AcceptChanges method, hit F12. Set breakpoints there, and make sure that the method does not swallow the changes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|