Setting ListView Focused Color
I am managing colors in my list view and setting the entire row to a given
color. If I select a row and then click in an area that does not have a
row, my previously selected row draws as white because it still has the
focus. There are too many scenarios that I would have to reset the focus.
Is there a way to set the focus color of the listview so that I never see
the white focused selection? Tag: problem: events for a form in a panel in a child window Tag: 57502
(Urgent)Regarding : STAThreadAttribute
Hi there,
I want to copy a Image to the clipboard. When i try to do so following
exception occurs :
"The current thread must set to Single Thread Apartment (STA) mode before
OLE calls can be made. Ensure that your Main function has
STAThreadAttribute marked on it"
Following are the points i want to say :
1. Which is the main method in windows forms ? When i tried to assign
<STAThread()> attribute to Public sub New () it gave me error.
2. I tried adding module contaning public sub main() assigning <STAThread()>
attribute, but above exception continues.
3. When i am checking the Threading.Thread.CurrentThread.ApartmentState
property in the function where exception is there , it is showing me the
value 1.
4. In my whole application I have never used Threads manually.But it does
contain many events.
Application i am working on is based on Client Server Architecure and
the code which gives exception is written on Server Side.This code gets
executed when request is received from the client.
Plz give me suggestions, its very URGENT.
Thanks in advance.
Chandrakant Shinde Tag: problem: events for a form in a panel in a child window Tag: 57500
Change Graph Line Colors at Runtime?
Using Crystal Reports 9 RDC, VS Studio 2003, C#, Client/Server Application
with Windows Forms.
Is it possible to change the graph line colors in a chart at runtime?
If so, does anyone have sample code for C#? Thanks in advance! Tag: problem: events for a form in a panel in a child window Tag: 57499
Catch key press in a datagrid
I have a windows forms data grid where I want to disallow the editing of
certain cells. At the moment though I can't get any code to trigger,
whether I include it in any of the DataGrid_KeyDown/Up/Press events.
Hopefully, I'm just doing something very silly.
--
Rob Oldfield
www.realuk.co.uk Tag: problem: events for a form in a panel in a child window Tag: 57498
Fill a combo box from collection, but bind to a custom class?
I am trying to do something a little nonstandard, and am having some
difficulty determining (a) if it can be done and (b) if so, how to do it.
What I want to do is fill a dropdown combobox with data from a collection.
Then, I want to bind that list to a member of a custom class. (Don't ask
why, just trust me on that one. <gr>).
What I'm doing now is binding the combo box to a collection, as follows:
Dim items As ArmorTypeCollection = ArmorTypeDac.Select()
With Me.ArmorType
.DataSource = items
.DisplayMember = "Value"
.ValueMember = "ID"
End With
Then, when the data is loaded onto the form, I set the default member as
follows:
Dim item As ArmorType
For Each item In ArmorType.Items
If item.ID.ToString() = _armor.Type.ID.ToString() Then
ArmorType.SelectedItem = item
Exit For
End If
Next
When the user commits her changes, I load them back into the object as
follows:
_armor.Type = ArmorTypeDac.Select().Item(Me.ArmorType.SelectedValue())
Is there a better way to do this? Essentially, my _armor object (of type
Armor) has a reference to an item in the armor type collection.
Any help would be greatly appreciated. Tag: problem: events for a form in a panel in a child window Tag: 57492
BUG Report. Please confirm.
Hi,
I'm previously haunted by a bug which is now in Knowledge Base Article
818587 (Fix: Regression in Dataset Serialization in Visual Studio .NET 1.1
when a datarow contains a rowError or a ColumnError Property) which can be
found at http://support.microsoft.com/default.aspx?scid=kb;en-us;818587.
Please note that this bug only shows itself if the Windows Form Application
is run on dotNetFramework 1.1 but does not shows itself if the same
application is forced to run on dotNetFramework 1.0
Now, I think I found another bug which produces the same error message as
the bug above and it also has something to do with the rowError or a
ColumnError property. Even worse, the bug exists in dotNetFramework 1.1 and
also dotNetFramework 1.0. The error message is,
System.InvalidOperationException: There is an error in XML document (x,
xxxx).
---> System.NullReferenceException: Object reference not set to an
instance of an object.
To reproduce the bug,
1. Create a Web service with a dummy method.
<WebMethod()> Public Function Dummy(ByVal ds As DataSet) As DataSet
Return ds
End Function
2. Create a Windows Application or a Console Application and add the service
that you created in step 1 as a Web Reference.
3. Type in or paste the following code,
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim ws As localhost.Service1
Dim ds As DataSet
Dim dt As DataTable
Dim row As DataRow
Dim i As Integer
' Create a new DataTable
dt = New DataTable
dt.TableName = "TestTable"
dt.Columns.Add("TestColumn1", GetType(String))
dt.Columns.Add("TestColumn2", GetType(Integer))
' Create a new DataSet and add the DataTable into it
ds = New DataSet
ds.DataSetName = "TestDataSet"
ds.Tables.Add(dt)
' Fill the DataTable with dummy values
For i = 0 To 10
row = dt.NewRow
row("TestColumn1") = "This is row " & i
row("TestColumn2") = i
dt.Rows.Add(row)
Next
' Set error message to the rows
For Each row In ds.Tables("TestTable").Rows
' Setting the RowError property below will cause and
' exception is thrown when calling ws.Dummy(ds.GetChanges).
row.RowError = "Row has not been updated to the server yet."
Next
' Send DataSet to the WebService
Try
ws = New localhost.Service1
ws.Dummy(ds.GetChanges)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
ws.Dispose()
End Sub
Can anyone confirm this? Thanks a lot. Tag: problem: events for a form in a panel in a child window Tag: 57488
Problems with Inherited Forms....
Hi,
I've created a new template class with some forms. one of
them is a main form (a MDIContainer-Form) with some
controls. It also contains a simple menu (everything is
PUBLIC).
Ok. Now I've a new project. I've created a new form
inheriting my templateform. Now, I'm able to add some menu
items to the menucontrol. So far so good, but if I close
the form (within the designer) and reopen it again : I
loose all my menuitems ! But if I run the project ->
everything is on my form !! So, the CODE for the menuitems
is there, but the designer doesn't show these..is this a
problem with the sub intializecomponent ? Any ideas ?
Thanks for your help.
Cheers,
Dominic Tag: problem: events for a form in a panel in a child window Tag: 57475
How to disable my Component in the toolbox?
Hi,
i have written a custom component that derives from
System.ComponentModel.Component.
It gets added to the toolbox correctly but I want it
to only be droppable on Forms, not on UserControls etc.
When a Form is currently displayed, the component should
be enabled in the toolbox, otherwise not.
Like the MainMenu component toolbox item does. It is
disabled when a UserControl is in design mode.
How do I get the same effect?
TIA
Martin Tag: problem: events for a form in a panel in a child window Tag: 57474
Escape characters in RichTextBox....
Hi !
I have a form. The form has a textbox and a richtextbox.
There is a button also. When the button is clicked,
whatever text was typed into the text box, must be copied
to the richtextbox.
At runtime, I enter the following string into the text
box:
Hi\nHello\nHow\nDo\nYou\nDo
Then I click the button. In the richtextbox I am expecting
Hi
Hello
How
Do
You
Do
But what I get is:
Hi\nHello\nHow\nDo\nYou\nDo
Ne idea to workaround this probs?
...Sinex Tag: problem: events for a form in a panel in a child window Tag: 57473
PropertyGrid with Multiple Selections
I have a propertygrid on a form, and I set SelectedObject or
SelectedObjects.
Everything is working perfectly if I set the PropertySort =
CategorizedAlphabetical.
If, however, I set the sort to Categorized, and then select multiple
objects, the property grid does not show all the properties that it
should show. For example, if I select 2 objects, both having
properties Hole1...Hole18, Hole2..9, and Hole18 show up but
1,10,11,12,13,14,15,16,17 do not show up.
Does anyone have an idea why? I am using a
System.ComponentModel.TypeConverter on the object that Hole1..Hole18
points to along with a UITypeEditor.
Just to repeat, EVERYTHING works fine if I set to
CategorizedAlphabetical. Everything except all the properties work
fine if set to Categorized.
Please do not ask WHY I am setting to categorized (it's just what I
want) or ask if stuff is working properly besides the display. They
all are working properly. Tag: problem: events for a form in a panel in a child window Tag: 57472
Control tips
I think I must be going mad. This has to be included in .Net and I just
can't find it. Controls on a windows form. How do I get explanatory text
to display when the user hovers the mouse over a control? (i.e. the stuff
that Access calls control tips)
Thanks.
--
Rob Oldfield
www.realuk.co.uk Tag: problem: events for a form in a panel in a child window Tag: 57471
Language support for UI application in win98
Hi all,
I have developed a application that supports localization in .net.
It shows all the controls with english and hindi text depending on the
culture selected.
The application runs well on windows 2000 and windows xp but when run on
windows 98 the hindi text appears as garbage. Can anyone help out
with this.(I have installed the .net framework on windows 98)
Regards,
Kuldeep Pawar
Programmer,
Maximize Learning, Pune. Tag: problem: events for a form in a panel in a child window Tag: 57454
Integral Number of Text Lines in RichTextBox
Hello,
I would like to set up a RichTextBox so that the text
shows an integral number of text lines when the text box
is scrolled all the way down. How can this be done?
I tried this: I set ClientSize.Height to be a multiple of
Font.Height, verify that it's set, but I get slightly
fewer than the expected number of lines. This means that
when the text box is scrolled all the way down, part of a
line shows at the top, which looks bad.
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
class TextBoxTesterForm : Form
{
public TextBoxTesterForm()
{
d_rtb = new RichTextBox();
d_rtb.SuspendLayout();
d_rtb.Parent = this;
d_rtb.Location = new Point(10,10);
int desiredTextHeight = lines * d_rtb.Font.Height;
d_rtb.ClientSize = new Size(200, desiredTextHeight);
d_rtb.ResumeLayout();
Console.WriteLine("lines={0}", lines);
Console.WriteLine("rtb Font.Height = {0}",
d_rtb.Font.Height);
Console.WriteLine("rtb Font.GetHeight() = {0}",
d_rtb.Font.GetHeight());
Console.WriteLine("desiredTextHeight = {0}",
desiredTextHeight);
Console.WriteLine("rtb ClientSize = {0}",
d_rtb.ClientSize);
Console.WriteLine("rtb DisplayRectangle = {0}",
d_rtb.DisplayRectangle);
Console.WriteLine("rtb Size = {0}", d_rtb.Size);
Console.WriteLine("rtb Multiline = {0}", d_rtb.Multiline);
}
RichTextBox d_rtb;
int lines = 5;
}
class TextBoxTestMain {
static void Main()
{ Application.Run(new TextBoxTesterForm()); }
} Tag: problem: events for a form in a panel in a child window Tag: 57449
CheckedListBox crashes after complex datasource is modified
Hi,
I am using a checkedlistbox on a windows form and binding it to a
collection of classes.
clbAliases is the checkedlistbox control
selectedplace is a class with property placealiases.This property is a
collection of placealias classes. Hopefully the rest is
self-explanatory..
I bind the control as follows:
If SelectedPlace.PlaceAliases.Count > 0 Then
SetCLBAliasDataSource()
Else
clbAliases.DataSource = Nothing
End If
Private Sub SetCLBAliasDataSource()
clbAliases.DataSource = Nothing
clbAliases.DisplayMember = "AliasName"
clbAliases.DataSource = SelectedPlace.PlaceAliases
End Sub
Then when I modify the underlying collection ( specifically for delete
functionality )
I have this:
Private Sub btnDeleteAlias_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteAlias.Click
If SelectedPlace.PlaceAliases.Count = 1 Then
MsgBox("You cannot delete the primary alias.")
Exit Sub
Else
Dim item As Object
For Each item In clbAliases.CheckedItems
'clbParents.Items.Remove(item)
SelectedPlace.PlaceAliases.Remove(item.placenameid)
Next
'this forces the control to rebind to the modified
collection
SetCLBAliasDataSource
End If
End Sub
Everything works as expected, EXCEPT once the item is removed, and the
user clicks into the checkedlistbox area , specifically on any
remaining item in the box, the following error occurs:
"An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative
and less than the size of the collection."
I have experimented with refreshing the checkedlistbox, and a number
of various other attempted workarounds without success.
The error occurs whether I specify a ValueMember property or not. When
I inspect the underlying collection in the locals window, it appears
normal, as does the items collection of the control. And both contain
the expected number of items. In addition the control correctly
displays the remaining items.
I can only assume that the control is referencing a non-existent
collection member somewhere in the click event event args. Execution
breaks on the line with the class definition :
Public Class GISMain
Can anyone point out a workaround, or my mistake??
Thanks in advance for any help..
Matthew Evans
Someone replied in another ng saying that checkedlistboxes were flaky,
specifically on 1.0... So I tried a rebuild of the application on
VS.2003 / V1.1 of the framework , and the error occurs there too. the
error message on that platform is :
"An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in microsoft.visualbasic.dll
Additional information: Specified argument was out of the range of
valid values."
Similar, but not identical....
Once again, any help / pointers much appreciated... Tag: problem: events for a form in a panel in a child window Tag: 57432
Getting data from a datagrid
Hello,
I have a bound datagrid called dgjobs that is bound
to a dataset called dsjobs using the following code.
Me.dgJobs.DataSource = dsJobs.Tables!Jobs
cm = CType(Me.BindingContext(dsJobs.Tables!jobs),
CurrencyManager)
The grid populates just fine however when the
currentcellchanged event is triggered (i.e. when you
scroll or click another row) I wish to get the value of the
first column (jobkey) in the currently selected row so
that I may use this as a parameter for a procedure. Any
ideas how I can read the data from the grid.
Thanx in advance
Robert Batt Tag: problem: events for a form in a panel in a child window Tag: 57421
Layout problem - Mainmenu + toolbar + a "filled" control
I have a form that has a main menu (dock: top) and a tookbar (dock: top)
I tried to insert a control that is (dock: fill)
I found that the toolbar actually 'covered' the top of the 'filled'
control....
how should I solve this?! Tag: problem: events for a form in a panel in a child window Tag: 57420
Process -> MainWindowHandle always coming back as 0???
I'm using a mutex to ensure only 1 instance of my app is created. It works
fine.
If an instance of my app IS already running, I want to use the following
code to bring the window to the foreground. BUT, the MainWindowHandle is
always 0 (I checked all processes and they are all 0). How can I get the
window handle back? Or, is there another way to popup my application?
Thanks,
Steve
if (!grantedInitialOwnership)
{
Process[] ps =
Process.GetProcessesByName("AppName");
IntPtr hWnd = ps[0].MainWindowHandle;
// Show existing instance
if (hWnd.ToInt64() != 0)
{
SetForegroundWindow(hWnd);
ShowWindow(hWnd, 5); // SW_SHOW
}
} Tag: problem: events for a form in a panel in a child window Tag: 57414
The listmanager's position must be equal to rownum.
Please help me.
I must correct this error :
The listmanager's position must be equal to rownum.
Parameter name : rownum do you want to correct the value ?
I have this error with VS2002 and also with VS2003.
______________________
I'd like to have a datagrid with all the columns of my table EXAMPLE and a
new column with a checkbox to select some row.
So.. i use a select to put my data in my data adapter.
( SELECT example.ID, example.name, ...........,false as col_for_sel
.... the col_for_sel is the column that i'll use to check or not the row )
I fill with my D.A. a new datatable....
I'll use a data grid to view my data with a datagridestyle.
I don't know what i can control :-(
-------------------------------- Tag: problem: events for a form in a panel in a child window Tag: 57408
Preventing deletion of certain characters
In a textbox control, how can you prevent the deletion of
certain characters? For example, a user shouldn't be able
to delete the backslash "/" character but can delete other
characters. Thanks a lot :) Tag: problem: events for a form in a panel in a child window Tag: 57405
Validating events
Hello,
How can i disable the Validating Event of all the controls of a form after a
click on a Cancel Button and close the Form?
Or how can fix the order of Validating events of the controls in a Form?
Thanks in advance.
Pascal Tag: problem: events for a form in a panel in a child window Tag: 57401
How to get App path of WinService
I was using Environment.CurrentDirectory when I tested my class in a winform
wrapper, but but now that I've move it to a WinService this gives me
"C:\WinNT\System32"
How can I get the Path of my assembly?
Thanks in Advance,
Byron Tag: problem: events for a form in a panel in a child window Tag: 57397
adding objects to the Clipboard in .Net
The preceeding message is on
XP Pro using Visual Studio .Net
and C#. Tag: problem: events for a form in a panel in a child window Tag: 57394
adding objects to the clipboard in .NET
I am unable to add a button to the clipboard. This is
required to do drag and drop of the object - button.
I am able to add a string to the clipboard. The following
is a summary of my steps. Any help greatly appreciated.
Button button2 = new Button();
DataObject data = new DataObject();
data.SetData("myButton", button2);
Clipboard.SetDataObject(data, true);
IDataObject data = Clipboard.GetDataObject();
object obj = data.GetData("myFormat"); // returns obj
== null
Button btn = (Button)data.GetData("myFormat"); //
returns btn == null
btn = (Button)data.GetData(typeof(Button)); // returns
btn == null
Thanks... Tag: problem: events for a form in a panel in a child window Tag: 57393
WinService Uninstall failed How do I clean up?
Hi, I followed the tutorial for setting up a WinService install and got the
messages below. If it's already on the system as it says then I should be
able to see it in the Services list but I didn't see it there.
How can I remove a WinService manually?
Thanks in Advance,
Byron
-------------
InstallUtil.InstallLog:
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the c:\program files\twsm\ecpu\ecpu.exe
assembly's progress.
The file is located at c:\program files\twsm\ecpu\ecpu.InstallLog.
An exception occurred during the Install phase.
System.ArgumentException: Source eCPU already exists on the local computer.
The Rollback phase of the installation is beginning.
See the contents of the log file for the c:\program files\twsm\ecpu\ecpu.exe
assembly's progress.
The file is located at c:\program files\twsm\ecpu\ecpu.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
------------
eCPU.InstallLog:
Installing assembly 'c:\program files\twsm\ecpu\ecpu.exe'.
Affected parameters are:
assemblypath = c:\program files\twsm\ecpu\ecpu.exe
logfile = c:\program files\twsm\ecpu\ecpu.InstallLog
Installing service eCPU...
Creating EventLog source eCPU in log Application...
Rolling back assembly 'c:\program files\twsm\ecpu\ecpu.exe'.
Affected parameters are:
assemblypath = c:\program files\twsm\ecpu\ecpu.exe
logfile = c:\program files\twsm\ecpu\ecpu.InstallLog
Restoring event log to previous state for source eCPU. Tag: problem: events for a form in a panel in a child window Tag: 57385
Can't start new projects in VS 2003
I can start a new project in VS2003, and don't put any controls or code in
form1, leave everything as VS writes it. Now I run it. Should just pop up a
blank form right? UhUh.
An unhandled exception of type "System.NullreferenceException' occurred
in Unknown Module.
Additional information: Object reference not set to an instance of an
object.
If you break there is no code for the current location. The app will build
without errors but I can't run it outside of vs either.
I can do this over and over again (definition of stupid) Once a few days
ago, I started one of these in a directory other than the default (actually
a subdirectory) and it worked and I could then write a small utility without
further problems. Runs fine in debugger still.
However it doesn't seem to make any difference where I put a new project
now.
I have read every forum posting on this problem and tried everything
suggested. Have also uninstalled and reinstalled the framework 1.1 as well
as VS twice to no avail.
Suggestions?
Many thanks Tag: problem: events for a form in a panel in a child window Tag: 57384
.Net App deployment - Removing files problem
How do I instruct the Windows installer to remove the entire application
when the user clicks Remove program from Windows control panel?
After a successful setup, any files created by the application in the
application folder are not removed. This is so when the program is
"removed" from the Windows control panel. This becomes a problem if the
user decides to reinstall the application in the same location. The
*old*/legacy files, e.g. app config files, may cause a problem with the
*new* installation of the application file.
My installer program was created with a "setup and deployment" type project
is Visual Studio.NET 2003 for a .NET v 1.1 Windows Forms application. It
appears all of the property pages in the VS.NET editor address installation
and few removal issues. I reckon I'm sniffing around for a solution in the
wrong place.
--
Peter O'Reilly Tag: problem: events for a form in a panel in a child window Tag: 57382
.Net App deployment - Removing files problem
How do I instruct the Windows installer to remove the entire application
when the user clicks Remove program from Windows control panel?
After a successful setup, any files created by the application in the
application folder are not removed. This is so when the program is
"removed" from the Windows control panel. This becomes a problem if the
user decides to reinstall the application in the same location. The
*old*/legacy files, e.g. app config files, may cause a problem with the
*new* installation of the application file.
My installer program was created with a "setup and deployment" type project
is Visual Studio.NET 2003 for a .NET v 1.1 Windows Forms application. It
appears all of the property pages in the VS.NET editor address installation
and few removal issues. I reckon I'm sniffing around for a solution in the
wrong place.
--
Peter O'Reilly Tag: problem: events for a form in a panel in a child window Tag: 57380
Changing the line colors of a Crystal Report at runtime?
Hello
I am running .NET 2003, Framwork 1.1, Crystal Report Version 9. I am writing
all my code in C#.
I have two questions:
1) Does anyone know if the line color in a chart on a Crystal Report can be
changed at runtime?
2) Does anyone know if a report can be created from a collection?
If the answer to either of these is yes, can you please supply sample code
in either VB.NET or C#.NET? Thanks in advance for your time!
Ken Tag: problem: events for a form in a panel in a child window Tag: 57378
inputbox for C#
Hello,
Just wondering if there is an equivelant available to C#
for quick string input. I am NOT using vb.net so i cant
use that version.
TIA,
Mel Tag: problem: events for a form in a panel in a child window Tag: 57374
Can't disable Add New row at bottom of Datagrid
--------------F34FF1FF13222AD377793457
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Based on this post from Clay Burch and the SyncFusion FAQ website, I
tried to disable my add new row at the bottom of my datagrid. However
the add new row still shows up. When I click on it my app crashes. Can
anybody look at the routine I've included at the bottom and tell me what
I did wrong?
Thanks,
Steve
Clay's Post:
You can do this by getting at a dataview associated with the datagrid,
and
setting its AllowNew member. Here is one way you can do this.
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
//no adding of new rows
((DataView)cm.List).AllowNew = false;
===================================
Clay Burch
Syncfusion, Inc.
My Routine:
private void loadMessagesDataGrid(ref DataTable msgsDataTable)
{
DateTime startDateTime = DateTime.Now.AddDays(-1);
string messagesSelectStr = "SELECT id, fldtimestamp, "+
"payload, direction, state, transNum, port "+
"FROM messages "+
"WHERE port = "+Port+" "+
"AND fldtimestamp > #"+startDateTime+"# "+
"ORDER BY fldtimestamp DESC";
// Create data adapter objects
MessagesDataAdapter = new OleDbDataAdapter(messagesSelectStr,
Db.getConnection());
MessagesDataAdapter.TableMappings.Add("Table1", "messages");
createMessagesInsertAndUpdateCommands(MessagesDataAdapter, Db);
try
{
MessagesDataAdapter.Fill(dgDataSet, "messages");
}
catch (Exception ex)
{
Log.WriteLine("Exception Filling messagesDataAdapter: "+ex.Message);
return;
}
DataGridTableStyle messagesStyle = null;
try
{
messagesStyle = new DataGridTableStyle();
messagesStyle.MappingName = "messages";
}
catch (Exception ex)
{
Log.WriteLine("Exception getting DataGridTableStyle: "+ex.Message);
return;
}
// HERE IS THE FIRST LINE SUGGESTED BY SYNCFUSION
CurrencyManager cm = (CurrencyManager)BindingContext[dgDataSet,
"messages"];
try
{
int numCols = dgDataSet.Tables["messages"].Columns.Count;
DataGridColoredTextBoxColumn aColumnTextColumn ;
for(int i = 0; i < numCols; ++i)
{
aColumnTextColumn = new DataGridColoredTextBoxColumn(this);
aColumnTextColumn.HeaderText =
dgDataSet.Tables["messages"].Columns[i].ColumnName;
aColumnTextColumn.MappingName =
dgDataSet.Tables["messages"].Columns[i].ColumnName;
if(i == 1) // fldtimestamp
{
aColumnTextColumn.Format = "g";
}
messagesStyle.GridColumnStyles.Add(aColumnTextColumn);
}
messagesStyle.GridColumnStyles["fldtimestamp"].Width = 110;
messagesStyle.GridColumnStyles["payload"].Width = 250;
messagesStyle.GridColumnStyles["direction"].Width = 0;
messagesStyle.GridColumnStyles["state"].Width = 75;
messagesStyle.GridColumnStyles["transNum"].Width = 0;
messagesStyle.GridColumnStyles["port"].Width = 0;
messagesDataGrid.TableStyles.Clear();
messagesDataGrid.TableStyles.Add(messagesStyle);
// HERE IS THE SECOND LINE SUGGESTED BY SYNCFUSION
((DataView)cm.List).AllowNew = false;
}
catch (Exception ex)
{
Log.WriteLine("Exception setting up TableStyles: "+ex.Message);
return;
}
// bind messages data grid with messages data table
try
{
msgsDataTable = dgDataSet.Tables["messages"];
messagesDataGrid.DataSource = msgsDataTable;
msgsDataTable.DefaultView.Sort = "fldtimestamp DESC";
}
catch (Exception ex)
{
Log.WriteLine("Exception: "+ex.Message);
}
}
--------------F34FF1FF13222AD377793457
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<br>Based on this post from Clay Burch and the SyncFusion FAQ website,
I tried to disable my add new row at the bottom of my datagrid. However
the add new row still shows up. When I click on it my app crashes.
Can anybody look at the routine I've included at the bottom and tell me
what I did wrong?
<br>Thanks,
<br>Steve
<p>Clay's Post:
<p><font face="Courier New,Courier"><font size=-1>You can do this by getting
at a dataview associated with the datagrid, and</font></font>
<br><font face="Courier New,Courier"><font size=-1>setting its AllowNew
member. Here is one way you can do this.</font></font>
<br><font face="Courier New,Courier"><font size=-1></font></font> <font face="Courier New,Courier"><font size=-1></font></font>
<p><font face="Courier New,Courier"><font size=-1>CurrencyManager cm =</font></font>
<br><font face="Courier New,Courier"><font size=-1>(CurrencyManager)this.BindingContext[dataGrid1.DataSource,</font></font>
<br><font face="Courier New,Courier"><font size=-1>dataGrid1.DataMember];</font></font><font face="Courier New,Courier"><font size=-1></font></font>
<p><font face="Courier New,Courier"><font size=-1>//no adding of new rows</font></font>
<br><font face="Courier New,Courier"><font size=-1>((DataView)cm.List).AllowNew
= false;</font></font><font face="Courier New,Courier"><font size=-1></font></font>
<p><font face="Courier New,Courier"><font size=-1>===================================</font></font>
<br><font face="Courier New,Courier"><font size=-1>Clay Burch</font></font>
<br><font face="Courier New,Courier"><font size=-1>Syncfusion, Inc.</font></font>
<p>My Routine:
<br> private void loadMessagesDataGrid(ref DataTable msgsDataTable)
<br> {
<br> DateTime startDateTime = DateTime.Now.AddDays(-1);
<br> string messagesSelectStr = "SELECT id, fldtimestamp, "+
<br> "payload, direction, state, transNum, port "+
<br> "FROM messages "+
<br> "WHERE port = "+Port+" "+
<br> "AND fldtimestamp > #"+startDateTime+"# "+
<br> "ORDER BY fldtimestamp DESC";
<p> // Create data adapter objects
<br> MessagesDataAdapter = new OleDbDataAdapter(messagesSelectStr,
Db.getConnection());
<br> MessagesDataAdapter.TableMappings.Add("Table1", "messages");
<p> createMessagesInsertAndUpdateCommands(MessagesDataAdapter,
Db);
<p> try
<br> {
<br> MessagesDataAdapter.Fill(dgDataSet, "messages");
<br> }
<br> catch (Exception ex)
<br> {
<br> Log.WriteLine("Exception Filling messagesDataAdapter:
"+ex.Message);
<br> return;
<br> }
<p> DataGridTableStyle messagesStyle = null;
<br> try
<br> {
<br> messagesStyle = new DataGridTableStyle();
<br> messagesStyle.MappingName = "messages";
<br> }
<br> catch (Exception ex)
<br> {
<br> Log.WriteLine("Exception getting DataGridTableStyle:
"+ex.Message);
<br> return;
<br> }
<br>
<br>// HERE IS THE FIRST LINE SUGGESTED BY SYNCFUSION
<br> CurrencyManager cm = (CurrencyManager)BindingContext[dgDataSet,
"messages"];
<br> try
<br> {
<br> int numCols = dgDataSet.Tables["messages"].Columns.Count;
<br> DataGridColoredTextBoxColumn aColumnTextColumn ;
<br> for(int i = 0; i < numCols; ++i)
<br> {
<br> aColumnTextColumn = new DataGridColoredTextBoxColumn(this);
<br> aColumnTextColumn.HeaderText = dgDataSet.Tables["messages"].Columns[i].ColumnName;
<br> aColumnTextColumn.MappingName = dgDataSet.Tables["messages"].Columns[i].ColumnName;
<br> if(i == 1) // fldtimestamp
<br> {
<br> aColumnTextColumn.Format = "g";
<br> }
<br> messagesStyle.GridColumnStyles.Add(aColumnTextColumn);
<br> }
<p> messagesStyle.GridColumnStyles["fldtimestamp"].Width
= 110;
<br> messagesStyle.GridColumnStyles["payload"].Width
= 250;
<br> messagesStyle.GridColumnStyles["direction"].Width
= 0;
<br> messagesStyle.GridColumnStyles["state"].Width =
75;
<br> messagesStyle.GridColumnStyles["transNum"].Width
= 0;
<br> messagesStyle.GridColumnStyles["port"].Width = 0;
<p> messagesDataGrid.TableStyles.Clear();
<br> messagesDataGrid.TableStyles.Add(messagesStyle);
<p>// HERE IS THE SECOND LINE SUGGESTED BY SYNCFUSION
<br> ((DataView)cm.List).AllowNew = false;
<p> }
<br> catch (Exception ex)
<br> {
<br> Log.WriteLine("Exception setting up TableStyles:
"+ex.Message);
<br> return;
<br> }
<p> // bind messages data grid with messages data table
<br> try
<br> {
<br> msgsDataTable = dgDataSet.Tables["messages"];
<br> messagesDataGrid.DataSource = msgsDataTable;
<br> msgsDataTable.DefaultView.Sort = "fldtimestamp DESC";
<br> }
<br> catch (Exception ex)
<br> {
<br> Log.WriteLine("Exception: "+ex.Message);
<br> }
<br> }
<br>
</body>
</html>
--------------F34FF1FF13222AD377793457-- Tag: problem: events for a form in a panel in a child window Tag: 57371
Tab Control with Combo Box
I have a windows form that contains a tab control. On
one of the tabs I have a combo box bound to a datatable.
When I first enter the tab I initialize the selectedindex
of the combobox to -1. I then type text into the combo
box that does not match any entries in the dropdown
list. If I then choose a different tab and return to my
tab with the combo box, the selectedindex has been
changed to 0 and the text I entered is replaced with the
text from list item 0. Why does the combo box not retain
a selectedindex of -1 with the text I entered? How can I
correct this?
Thank You,
Don Tag: problem: events for a form in a panel in a child window Tag: 57370
Help with ListView
I am trying to get data from a CollectionBase derived class into a ListView.
Currently the output is one continuous line of data that is of Boolean type
e.g. True True False True False False False True .
No other data or header information is displayed.
public class RecFormCtxSaved
{
private Boolean enabled;
private Boolean selected;
private string column;
private string text;
}
private void createListView()
{
ListViewItem lvi;
this.listView1.Columns.Add("Enable", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Select", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Column", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Text", 50, HorizontalAlignment.Left);
foreach (RecFormCtxSaved rec in coll)
{
lvi = new ListViewItem();
lvi.Text = rec.Enabled.ToString();
lvi.SubItems.Add(rec.Selected.ToString());
lvi.SubItems.Add(rec.Column);
lvi.SubItems.Add(rec.Text);
this.listView1.Items.Add(lvi);
}
} Tag: problem: events for a form in a panel in a child window Tag: 57367
Wish List Item - Slim CLR For Download
For Java code, there is a "slim" download from Sun that contains just
enough code to host an applet plus the capability to download other
classes/jars as needed. There are seperate options from Sun (SDK
download containing jar.exe, etc) for those that need more.
I wish the same could be done for the .NET CLR; I would like to host
"C# applets" in my web pages, but a 20mb download plus a reboot is a
lot to ask.
Why can't Microsoft distribute a "slim" CLR download weighing in
around 5mb that just contains the base classes for XML, Remoting,
System.Data, and WinForms, a "medium" one with some more features, and
still distribute the full sized one?" Tag: problem: events for a form in a panel in a child window Tag: 57366
OpenFileDialog ShowDialog hangs
Hi there,
has anyone run into this problem? I have a simple winforms app that
uses the OpenFileDialog to open a file. If I choose to open a file
from a different machine on my network everything is fine. However, if
I now close down my app and shutdown the other machine and try again
the OpenFileDialog hangs. The call stack shows that it is waiting in
RunFileDialog.
It looks as though the app persists the current directory somewhere,
but runs into trouble when that path is no longer available. When I
try the same thing with Word it goes back to My Documents when the
network path is not available.
Any ideas?
Thanks,
Tom Tag: problem: events for a form in a panel in a child window Tag: 57365
Lock fields
Hi
I am trying to lock fields on my form (VB.NET), so that they cannot be
edited by the user. So far I have accomplished my goal for the text box
by setting its read only property. But what should I do for combo box
and mask edit box (added as an reference). list box etc. I don't want to
use the enabled property, since that makes the controls text to fade or
not seen prominently.
Does anyone know how can we achieve this in VB.NET ??
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: problem: events for a form in a panel in a child window Tag: 57359
Datagrid question
I've a editable datagrid where the user sometimes needs to enter more
characters than can be displayed on the screen.
The current behavior is, I believe, a bit confusing to the user. When
they fill up the visible portion of the cell, the entered text moves
left off the screen, leaving the cursor in the left-most position of
the cell, ready to accept more data.
This is confusing because it appears that the entered text has
"disappeared". I'd rather have it behave like a standard textbox,
where it scrolls one character at a time when the visible width is
reached.
Is there a property that controls this behavior?
TIA. Tag: problem: events for a form in a panel in a child window Tag: 57358
No touch deployment - offline question.
Hi, I've been reading a lot about no touch deployment and it could be the
solution to my design. But I have a question:
What happens if the client is not 'connected'?
Is there anyway to run the app from the client chache?
Where can I find information about that?
I've read in some articles on MSDN about this posibility, but I can't find
any info about that.
Thanks in advance,
JOSE Tag: problem: events for a form in a panel in a child window Tag: 57350
question on docking
(sorry if you see this message twice - I got a "message expired" on my
last post)
Hi,
My GUI is driving me crazy. It's a little complicated, so I'll explain
the part that I find troubling:
I have a Panel which includes a UserControl of mine. The UserControl is
put in the Panel at runtime.
Although UserControl has Dock=Fill, resizing the Panel doesn't resize
the UserControl. (I check by hitting a breakpoint and using the
Immediate window)
How is this possible? Is there some other property I should set? Tag: problem: events for a form in a panel in a child window Tag: 57349
Framework Configuration
Hi!
As I can make to configure framework with one setup. The
configuration that I am to speak is:
Control Panel->Administrative Tools->Microsoft .NET
Framework 1.1 Configuration:
Run Time Security Police->Machine->Code Groups-
>All_code->Local_Intranet Zone and to insert a new rule
to have permissions to accede to an application that if
finds in another machine.
thx,
David Tag: problem: events for a form in a panel in a child window Tag: 57348
dll version
When I call a class in a dll from an application, how do I tell the version
of the dll as oposed to the application calling the dll?
Andrew Tag: problem: events for a form in a panel in a child window Tag: 57346
basic question on docking
Hi,
My GUI is driving me crazy. It's a little complicated, so I'll explain
the part that I find troubling:
I have a Panel which includes a UserControl of mine. The UserControl is
put in the Panel at runtime.
Although UserControl has Dock=Fill, resizing the Panel doesn't resize
the UserControl. (I check by hitting a breakpoint and using the
Immediate window)
How is this possible? Is there some other property I should set? Tag: problem: events for a form in a panel in a child window Tag: 57344