|
I need some help with a Problem in a DataGridView.
I have a DataGridViewComboBoxColumn bound to a list of Strings to select from.
If I select one of this items, it should be removed from the other cells dropdown
lists (in the same ComboBoxColumn). So that only the not selected Items are available to choose from.
(If I simply shorten the bounded list, I get a "DataGridView ComboBox Cell Value not valid" error.)
This sounds very easy, but in fact I spended several hours and could not solve this simple
task so far!
Can anybody help me?
Thanks!
Update:
I also tried to use a Datatable as Datasource, but when I remove an Item from the Datasource it has also the effect that it disappears from the cell it was formerly selected.
Update2:
Ok, I just tried it again and got a working solution myself.
Instead of binding the whole ComboboxColumn to a DataSource, I bind every cell for itself to a Datasource( or list). I use the CellBeginEdit event to Update the cells DataSource with the available Items.
This seems to work well
modified on Saturday, March 15, 2008 4:29 AM
|
|
|
|
|
I have a combobox bound to a BindingSource, in turn bound to a DataTable of Agent Names. Everything is handled by the VS 2008 designer, i.e. I have no custom data binding code, nor do I have any code that sets anything on the combobox. Yet, when I start my project, I get the following error:
InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
|
|
|
|
|
Brady Kelly wrote: I have no custom data binding code, nor do I have any code that sets anything on the combobox.
Well normally I would offer some advice about things like understanding the technology you are working with rather than thinking one can just drag and drop their way to quality software products but I'm pretty sure you and I have had that conversation and you rejected it, yes?
led mike
|
|
|
|
|
This has sweet nothing to do with me not understanding the technology, but only an idiot would just quietly accept it if one of his tools exhibited repeatable, anomalous behaviour. It is as much a desire of mine to understand my tools as well as to have them behave not only as expected, but also as indicated by the documentation.
|
|
|
|
|
It might be that your combo does not have any data in it (count = 0) and so throwing an exception when you try to set the SelectedIndex to 0 (which is item 1 on the combo).
Maybe you should check the data source to see if it actually returns some values...
|
|
|
|
|
I know it returns values. This only happens when the Break When Thrown debugging option is enabled. MS are actually swallowing an exception, and I suspect the reason it actually breaks when thrown is because I have the debug symbols and source code for the ComboBox installed on my machine.
|
|
|
|
|
I have set the alpha values of the brushes and pen, why isn't it blending into the form?
http://img153.imageshack.us/img153/2372/ss0001cn7.png[^]
Is there anyway to do this correctly?
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
<br />
this.AutoSize = false;<br />
this.BackColor = Color.Transparent;<br />
<br />
Graphics g = e.Graphics;<br />
<br />
g.SmoothingMode = SmoothingMode.AntiAlias;<br />
g.CompositingMode = CompositingMode.SourceOver;<br />
g.CompositingQuality = CompositingQuality.HighQuality;<br />
<br />
LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(alpha, Color.Gray), Color.FromArgb(alpha, Color.Silver), LinearGradientMode.Horizontal);<br />
g.FillRectangle(brush, this.ClientRectangle);<br />
<br />
Pen pen = new Pen(Color.FromArgb(alpha, Color.Red));<br />
g.DrawRectangle(pen, 0, 0, this.Size.Width - 1, this.Size.Height - 1);<br />
<br />
SolidBrush fontBrush = new SolidBrush(Color.FromArgb(alpha, Color.Black));<br />
g.DrawString("Crap", this.Font, fontBrush, 10.0f, 10.0f);<br />
}<br />
|
|
|
|
|
Hello,
Zerox MXI wrote: why isn't it blending into the form?
Because the Color.Transparent only means, that the Control shows the BackColor of the ContainerControl.
Apart from that, you have to care about your instanciated GDI object (Brushes, Pen, ...)!
They have to be" Dispose()";
You could call "fontBrush.Dispose();" or use a "using"- block:
using(SolidBrush fontBrush = new SolidBrush(Color.FromArgb(alpha, Color.Black)))
{
g.DrawString("Crap", this.Font, fontBrush, 10.0f, 10.0f);
}
Or hold the objects as long as the Control get's disposed and do the disposing there!
All the best,
Martin
|
|
|
|
|
As I am developing one windows application, I want to show one report to user. Previously iwas using datagrid but it dosen't solve the purpose as format of this report some thing like values in multiple rows and their respective totals. so I request you to please help me to create database driven dynamic table.
Thanx
Gurudatta B. Shelke
|
|
|
|
|
Hi,
You should try using the DataGridView control. It provides numerous basic and advanced features that are missing in the DataGrid control. Additionally, the architecture of the DataGridView control makes it much easier to extend and customize than the DataGrid control.
The following are the primary features available in the DataGridView control that are missing from the DataGrid control.
DataGridView control feature
Multiple column types
The DataGridView control provides more built-in column types than the DataGrid control. These column types meet the needs of most common scenarios, but are also easier to extend or replace than the column types in the DataGrid control.
Multiple ways to display data
The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together. You can also implement virtual mode in the DataGridView control to provide custom data management.
Multiple ways to customize the display of data
The DataGridView control provides many properties and events that enable you to specify how data is formatted and displayed. For example, you can change the appearance of cells, rows, and columns depending on the data they contain, or you can replace data of one data type with equivalent data of another type.
Multiple options for changing cell, row, column, and header appearance and behavior
The DataGridView control enables you to work with individual grid components in numerous ways. For example, you can freeze rows and columns to prevent them from scrolling; hide rows, columns, and headers; change the way row, column, and header sizes are adjusted; change the way users make selections; and provide ToolTips and shortcut menus for individual cells, rows, and columns.
Below is small code snippet showing how we can bind the grid to a data source
BEGIN CODE
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
customersDataGridView.DataSource = nwindDataSet;
customersDataGridView.DataMember = "Customers";
customersDataGridView.Sort(customersDataGridView.Columns["ContactName"], ListSortDirection.Ascending);
}
END CODE
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I am looking for a UI control where you can associate to any other control and as you mouse over the associated control, it will pop up to show more information or just about anything that I want to assign it to display. This control will remained visible until I move the mouse away from the associated control or the control itself. While the control is visible showing information, it can be updated to show some live results for instance progress of some value, etc.
I wonder if such a control have already existed or not and I won't have to reinvent the wheel if someone else had made it. If it's not, I guess I would have to make one for myself but unfortunately I'm not good at graphics related programming when it comes to winforms. I hope someone can point me to the right direction, probably some tutorials or certain articles in codeproject.com
Thanks in advance.
|
|
|
|
|
Zerox MXI wrote: I'm not good at graphics related programming when it comes to winforms.
In what context are you good at graphics related programming?
led mike
|
|
|
|
|
i "know" i did this once long ago, but for the life of me i can neither recall how nor find it on the web. any help would be greatly appriciated. (not sure if it's a IE7 vs IE 6 thing (im that lost))
i have a WebBrowser control on my form and i would like to invoke the "Send page by email" functionality. i tried stuff like this
<br />
int WM_COMMAND = 0x0111;<br />
int ID_IE_FILE_SENDPAGE = 279;<br />
m_NullPointer = IntPtr.Zero;<br />
m_hWBShellDocObjHandle = (IntPtr)0;<br />
<br />
HandleRef hr = new HandleRef(this.web, this.web.Handle);<br />
IntPtr ret = SendMessage(hr, (uint)WM_COMMAND, (IntPtr)ID_IE_FILE_SENDPAGE, m_NullPointer);<br />
Taken from here at the CP[^] )
and stuff like
<br />
web.Document.ExecCommand(......<br />
none work.
please point me the way
|
|
|
|
|
cechode wrote: i have a WebBrowser control on my form and i would like to invoke the "Send page by email" functionality.
Is there some problem with just sending the email using System.Web.Mail ?
led mike
|
|
|
|
|
This is a web browser control sitting on the clients’ machine. I want the default email client to send the email not an application configured email server. (figured the functionality should already be there) also tried the mailto option but then it seems that the body length is limited and I can not control the html format
|
|
|
|
|
|
I am trying to get a grasp of how to build some simple applications. So I went out and bought the .NET Framework Foundation Fundamentals book. It has taken me through some Labs to create console and Windows Form apps but other than those simple things I dont know how to use the classes I find here on this site and put them into a project. I know how to add the class to the project and drag some controls onto the page. I know some namespaces.
For example,
Read, write and delete from registry with C#
This is SUPER useful to us and I want to use it.
I wanted to take this class and create a windows form with a Button, TextBox, and Label. I wanted to be able to enter a keyword into the textbox and onbutton click it would search my registry and delete displaying the results in the label.txt.
Sounds simple enough? Other than dragging controls onto the form I have no clue how to put it together.
|
|
|
|
|
I would suggest two things. One is to stick with basic WinForms or Console applications, and focus on one small thing at a time, such as reading/writing a file, using collection classes, creating and using a class library, etc. until you are very comfortable with C#, the IDE, and these three project types: WinForms, Console, Class Library.
The second thing I would suggest is NOT messing with the registry just yet while you are learning. The registry is vital to Windows and should your program logic be off, your entire system may become unbootable.
When you focus on tdeveloping your building blocks, you'll start to naturally see how to combine them to create the solution you want.
|
|
|
|
|
In our application we are Using Infragistics 6.1.Some of the comboboxes in my application are not getting populated .Can someone TELL ME A sOLUTION
B.RAMYA
|
|
|
|
|
Ramya Bhaskaran wrote: Can someone TELL ME A sOLUTION
Go populate the combo boxes.
|
|
|
|
|
Could U tell the Problem in Clear?.
Sabarinathan T, India.
The interests are to know something about everything and everything about something...
|
|
|
|
|
I need to customize gridview control to display 2 rows in header.
Something like this
Name
First | Last
FN1 | LN1
FN2 | LN2
i.e.
"Name" is a group and "First" and "Last" are the columns under group "Name". These should be the header rows of my GridView.
this is very similar to Sheridan grid control for VB6.0.
Does any one know how to start with such a customization?
SPD
|
|
|
|
|
I have a lot of forms in my project and would like to better organize my code. I'd like to put certain forms in one name space and other forms in another namespace. How can I assign the namespace to a windows form?
|
|
|
|
|
weirbear wrote: How can I assign the namespace to a windows form?
Edit the code-behind and designer file.
|
|
|
|
|
I'm not sure what or where to put something in. I previously tried putting the namespace there but I just get a lot of errors. Can you show me an example?
|
|
|
|
|