473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Adding row to DataGrid

I am experiencing a problem when I add a row to a DataTable that is
used on a DataGrid in my Windows Form application. When I add a new
row I no longer get a response from my form. I see the row apear in the
DataGrid but still no response from the form. If I add the same data
to a rich text box and don't use the datagrid I don't have this
problem. What am I missing? It has to be something simple. Here is
my code snipet:

private void AddMessage(byte[] Data)
{
string Msg = ascii.GetString(Data); // Converts byte array of ascii
characters to string
int LessLoc = Msg.IndexOf("<", 0 , 1);// Should be first character
int GreaterLoc = Msg.IndexOf(">", 0, 5); //Can't be more than 5
characters into the message

if ((LessLoc > -1) && (GreaterLoc > 0))
{
string[] FSCombo =
FacilitySeverity(Convert.ToInt32(Msg.Substring(Les sLoc+1,
(GreaterLoc-LessLoc)-1)));

if ((FSCombo[0] != null) && (FSCombo[1] != null))
// rtxMsgs.Text += FSCombo[0] + ":" + FSCombo[1] + " - " +
Msg.Substring(GreaterLoc+1) + "\n";
SyslogTable.Rows.Add(new string[] {FSCombo[0], FSCombo[1],
Msg.Substring(GreaterLoc+1)} );
else
// rtxMsgs.Text += Msg + "\n";
SyslogTable.Rows.Add(new string[] {"", "", Msg.Substring(GreaterLoc+1)}
);
}
}

Here is how the DataGrid is setup:
this.dataGrid.CaptionVisible = false;
this.dataGrid.CausesValidation = false;
this.dataGrid.DataMember = "";
this.dataGrid.DataSource = this.SyslogTable;
this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGrid.Enabled = false;
this.dataGrid.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid.Location = new System.Drawing.Point(0, 0);
this.dataGrid.Name = "dataGrid";
this.dataGrid.ReadOnly = true;
this.dataGrid.RowHeadersVisible = false;
this.dataGrid.Size = new System.Drawing.Size(808, 373);
this.dataGrid.TabIndex = 1;
this.dataGrid.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
this.dataGridTableStyle1});

this.SyslogTable.Columns.AddRange(new System.Data.DataColumn[] {
this.dataColumnFacility,
this.dataColumnSeverity,
this.dataColumnMessage});
this.SyslogTable.TableName = "SyslogTable";

Thanks for the help!
--Mark

Nov 17 '05 #1
0 1643

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the datagrid during a button click (similar to...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
5
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
by: Praveen Balanagendra via .NET 247 | last post by:
here is the source code private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
1
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.