hello! Its me again. I hope somebody can help me!
I don't know if it is possible but i hope so...
i have a datagrid with 2 Columns:
1 Column is a checkbox (template) -
<DataGridTemplateColumn Header="geprüft">
-
<DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<CheckBox Name="chk" Content="{Binding Path=geprüft}" IsChecked="False" IsThreeState="False"/>
-
</DataTemplate>
-
</DataGridTemplateColumn.CellTemplate>
-
</DataGridTemplateColumn>
-
and the last Column is a textbox binding with status - <DataGridTextColumn IsReadOnly="True" Width="auto" Header="status" Binding="{Binding Status}">
now, i only want to show the checkbox if status = 4... so in row1 = show, row2 = hide etc...
is it possible?
and how can i make an event on the checkbox (to save in db if checkbox is checked)
if i make an event: -
Private Sub chk_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles chk.Click
-
End Sub
-
I get an error:
Error Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
hope somebody can help me!
Nice Greets,
Mathias
9 17205 Frinavale 9,735
Recognized Expert Moderator Expert
Hi Mathias,
Have you ever used converters before?
Create a class that implements the IValueConverter Interface so that you can bind your IsChecked property to the Status property. The converter will convert the 3, or 4 into a true or false value so that the IsChecked property will work.
-Frinny
Hello Frinny,
Thank you for your response! i try to do that... and hope it works.
But i think you don't understand what i need. (because my english is not so good)
1) I only want to see the checkbox when status = 4
If status = 3 or status = 2 or status = 1 then Hide the checkbox in the Row. (only visible on status = 4)
2) If i checked the checkbox in the row with status 4 i want to make an event in the Database. The Status should get the value 5 (Status 5 = Finished)
so is in this case the IValueConverter Interface the best solution?
nice Greets,
Mathias
ok now i have a solution for the checkbox to save something in database... i only add Click="CheckBox _Click"
Code to go in a sub :) -
-
<DataGridTemplateColumn Header="geprüft">
-
<DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<CheckBox Name="chk" Content="{Binding Path=geprüft}" IsChecked="False" IsThreeState="False" Click="CheckBox_Click"/>
-
</DataTemplate>
-
</DataGridTemplateColumn.CellTemplate>
-
</DataGridTemplateColumn>
-
But i have no solution for the first problem (checkbox visible or hidden for each rows)
Good Night, Good Fight!
Nice Greets,
Mathias
Frinavale 9,735
Recognized Expert Moderator Expert
You can get around this without using converters than...just use triggers like before but apply it to the CheckBox: -
<DataGridTemplateColumn>
-
<DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<CheckBox Name="chk" Content="{Binding Path=geprüft}" IsThreeState="False" Visibility="Collapsed">
-
<CheckBox.Style>
-
<Style TargetType="CheckBox">
-
<Style.Triggers>
-
<DataTrigger Binding="{Binding Path=Status}" Value="4">
-
<Setter Property="Visibility" Value="Visible" />
-
</DataTrigger>
-
</Style.Triggers>
-
</Style>
-
</CheckBox.Style>
-
</CheckBox>
-
</DataTemplate>
-
</DataGridTemplateColumn.CellTemplate>
-
</DataGridTemplateColumn>
It seems that you have solved your second part of the question.
-Frinny
Frinavale 9,735
Recognized Expert Moderator Expert
If you weren't using triggers, and you wanted to try a converter you would do the following.
You would create a class that implements the IValueConverter interface. The purpose of this class would be to return the visibility (collapsed or visible) depending on the Status value. The convert back method would set the status to 5...
I'm just not 100% sure if it would work because I can't really try it....
But your class would look something like this:
(VB.NET) -
Public Class StatusVisibilityConverter
-
Implements IValueConverter
-
-
Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
-
Dim is4Status As Boolean = CType(value, Integer)
-
-
If is4Status = 4 Then
-
Return Visibility.Visible
-
End If
-
-
Return Visibility.Collapsed
-
End Function
-
-
Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
-
Throw New NotImplementedException
-
'In here you would have to try converting back somehow...I'm just not sure how
-
End Function
-
End Class
(C#) -
public class StatusVisibilityConverter : IValueConverter
-
{
-
-
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
-
{
-
bool is4Status = Convert.ToInt32(value);
-
-
if (is4Status == 4) {
-
return Visibility.Visible;
-
}
-
-
return Visibility.Collapsed;
-
}
-
-
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
-
{
-
throw new NotImplementedException();
-
//In here you would have to try converting back somehow...I'm just not sure how
-
}
-
}
Add your project's namespace to your window/user control/page: - <Window x:Class="Window1"
-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-
xmlns:myProject="clr-namespace:MyProjectNamespace"
-
Title="Window1" Height="760" Width="800"
-
Background="White">
Add your visibility converter as a resource to the Window/User Control/Page...or even as a resource to your grid...so that you can use it: -
<Window.Resources>
-
<myProject:StatusVisibilityConverter x:Key="StatusVisibilityConverter" />
-
</Window.Resources>
-
Then change the XAML code for your CheckBox so that it's Visibility property is bound to your Status property and uses your new converter: -
<DataGridTemplateColumn>
-
<DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<CheckBox Name="chk" Content="{Binding Path=geprüft}" IsChecked="{Binding Path=Status}" IsThreeState="False"
-
Visibility="{Binding Path=Status, Converter={StaticResource StatusVisibilityConverter}}" />
-
</DataTemplate>
-
</DataGridTemplateColumn.CellTemplate>
-
</DataGridTemplateColumn>
-Frinny
Hi!
I try the first post (because I'm new in WPF) but it doesn't work... the property - <Setter Property="Visibility" Value="Visible" />
doesn't work?!
i try another Property - <Setter Property="IsEnabled" Value="false"/>
and it works... All other Properties work, but i don't know why the Property "Visibility " doesn't work...
Frinavale 9,735
Recognized Expert Moderator Expert
It would help if you posted the whole style because it worked when I tried it before posting...
-Frinny
now i tried your second post and it work!
thank you for your help!!!!!
Frinavale 9,735
Recognized Expert Moderator Expert
I'm glad it works.
Just make sure you implement the "convert back" method so that it works properly.
-Frinny
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: genetic.error |
last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up
before...
The VS.Net MSDN file seems to state that the following should work:
Form1.Show
Form1.Visible = True
Form1.Hide
Form1.Visible = False
Load (Form1)
|
by: soundar rajan |
last post by:
Hi,
I wanna display messagebox, and also at the bottom i wanna display "Dont
show again" with checkbox using VB.NET. Immediate help needed!!!!
|
by: Mac via DotNetMonster.com |
last post by:
I have a MDI parent form and the only control on it is a panel anchored to
the left hand side. I have menu items on the MDI parent that show & hide
this panel. Ideally I would like it to show by not pushing out the child
forms, but rather be overlapping them.
Alternatively I tried creating a form the same size as the panel but run
into...
|
by: DBC User |
last post by:
I am wondering is there any way when I do a show and hide of a form, we
can do a smooth transition to the new screen like power point
presentation in c#??
Thanks.
|
by: jesper_lofgren |
last post by:
Hi,
I wonder if its possible to show and hide a image with javascipt.
I want the image to disapear from bottom and up very smooth, maybe
under 3-4sec.
Is it possible ? any tips ?
Thanks
| |
by: Alistair George |
last post by:
Hi in Delphi its a piece of cake to show and hide a mainform eg
mainform.show mainform.hide.
However, after finding similar actions in C# seem to result in destroy
of form object, which causes errors maybe I am wrong, but here is what I
have tried with no joy:
private void TrayFormShow_Click(object sender, EventArgs e)
{...
|
by: timplx |
last post by:
Hello all,
New to javascript and have never worked with programming languages like c++, so my logic in some of these statements might be incorrect or redundant
Got a problem with my page...
using java and external css to show/hide items on the same click.
I found a script that uses the getElementById function to adjust the display style of a...
|
by: Frinavale |
last post by:
This code snippet is just a little bit of fun.
It demonstrates how you use JavaScript and CSS to show or hide columns in a table depending on whether or not a checkbox corresponding with the column is checked.
<html>
<head>
<script type="text/javascript">
function ShowHideField(header, gridID, checkboxElement) {
var theGrid =...
|
by: oranoos3000 |
last post by:
i read below text that say about initial state display in css and relate with show and hide dom element
do the below text describe this meaning that if we dont write display for element and hide that , it's display convert to hide and if again show that do convert display that to block or initial value related to html? for example for span if...
|
by: oranoos3000 |
last post by:
hi
my question is about jquery
string show or hide in css that is set inside jquery method animate , are special for some css property or can be set for any css that is set inside animate method ?for example show or hide is special opacity or can set for width and height and i thank you if you describe with detail.
and my another question...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |